harmony 鸿蒙Usage of Third- and Fourth-Party Libraries
Usage of Third- and Fourth-Party Libraries
How do I obtain available third-party libraries?
Applicable to: OpenHarmony 3.1 Beta5 (API version 9)
The three-party and four-party libraries that can be obtained through ohpm are summarized in the OpenHarmony-TPC/tpc_resource repository. You can access this repository, and find the desired component based on the directory index.
Which third-party libraries are related to network requests?
Applicable to: OpenHarmony 3.1 Beta5 (API version 9)
The following third-party libraries are related to network requests: Axios, httpclient, and okdownload. For details, see the OpenHarmony-TPC/tpc_resource repository.
How do I use ohpm to import third- and fourth-party libraries?
Applicable to: OpenHarmony 3.1 Beta5 (API version 9)
Solution
Method 1:
Open the Terminal window and run the following command to go to the entry directory:
cd entry
Run the following command to install a third-party library, for example, dayjs:
ohpm install dayjs
Add the following statement in the .js file to import the third-party library:
import dayjs from 'dayjs';
Method 2:
Enter the entry directory of the project and open the oh-package.json5 file.
Write the third-party library to be installed (for example, dayjs) in the oh-package.json5 file.
{ "dependencies": { "dayjs": "^1.10.4", } }
Open the Terminal window and run the following command to go to the entry directory:
cd entry
Run the following command to install the third-party library:
ohpm install
Add the following statement in the .js file to import the third-party library:
import dayjs from 'dayjs';
你可能感兴趣的鸿蒙文章
harmony 鸿蒙Using NDK in a CMake Project
harmony 鸿蒙Application Access Control Development
harmony 鸿蒙Application Model Development
harmony 鸿蒙ArkUI Animation/Interaction Event Development (ArkTS)
harmony 鸿蒙ArkUI Component Development (ArkTS)
harmony 鸿蒙ArkUI Development (JS)
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦