开云彩票(中国)官方网站-🦄开云彩票(中国)官方网站 ... rn: {...}-开云彩票(中国)官方网站

🦄开云彩票(中国)官方网站 ... rn: {...}-开云彩票(中国)官方网站

发布日期:2025-04-13 06:35  点击次数:200

🦄开云彩票(中国)官方网站    ...    rn: {...}-开云彩票(中国)官方网站

设置鸿蒙环境🦄开云彩票(中国)官方网站

下载装配 DevEco

设置IDE

绽开 Prefreences, OpenHarmony SDK, 勾选 API Version 12

创建鸿蒙神色

绽开 DevEco,点击 右上角Create Project, 在 Application 处聘请 Empty Ablity, 点击 Next, 插足设置页,凭据需求鬈曲试验,这里使用默许设置,

Project name: MyApplication,Bundle name: com.example.myapplication,Save location 聘请需要创建的目次,这里使用 MyApplication 目次 (~/projects/MyApplication)Compatible SDK, 聘请 4.0.0Module name: entry

防御,上头面前 Taro 扶持的 SDK 版块为 4.0.0

点击 Finish 完成神色创建。

装配 Taro 4.x

yarn global add @tarojs/cli

装配顺利后查验 taro 是否成效

➜ ~ taro --version Taro v4.0.74.0.7

运飘浮神色

taro init taro-ohos

按照教导输入,这里使用以下设置

? 请输入神色先容 taro ohos? 请聘请框架 React? 是否需要使用 TypeScript ? Yes? 请聘请 CSS 预处理器(Sass/Less/Stylus) Sass? 请聘请包处理器具 yarn? 请聘请编译器具 Vite? 请聘请模板源 Gitee(最快)✔ 拉取而已模板仓库顺利!? 请聘请模板 默许模板

恭候神色创建顺利,直到输出以下教导:

Done in 44.95s.✔ 装配神色依赖顺利创建神色 taro-ohos 顺利!请插足神色目次 taro-ohos 脱手职责吧!

装配鸿蒙插件

yarn add @tarojs/plugin-platform-harmony-etsyarn add path

修改编译设置

找到 config/index.ts 文献, 在 plugin 处添加 @tarojs/plugin-platform-harmony-ets, 在 rn 下方添加 harmony 设置:

import path from 'path'... ... plugins: [ '@tarojs/plugin-platform-harmony-ets' ], ... rn: {...}, harmony: { // 将编译模式成立为使用 Vite 编译 compiler: 'vite', // 【必填】鸿蒙主哄骗的悉数旅途,举例: projectPath: path.resolve(process.cwd(), '../MyApplication'), // 【可选】HAP 的称呼,默许为 'entry' hapName: 'entry', // 【可选】modules 的进口称呼,默许为 'default' name: 'default', }

防御这里要把 projectPath 成立成 Deveco 创建的鸿蒙神色目次

修改 package.json

在 scripts 处添加以下设置

"scripts": { ... "build:harmony": "taro build --type harmony", "dev:harmony": "npm run build:harmony -- --watch"}

运行 Taro 神色

yarn run dev:harmony

完结台输出以下试验,流露构建顺利:

build started... 点击查抄好意思满输出

yarn run v1.22.22$ npm run build:harmony -- --watch> taro-ohos@1.0.0 build:harmony> taro build --type harmony --watch Taro v4.0.7watching for file changes...build started...✓ 7 modules transformed.rendering chunks (6)...脱手 ohpm install 剧本扩充...install completed in 0s 36ms扩充 ohpm install 剧本顺利。../MyApplication/entry/src/main/ets/app.scss.xss.js 0.10 kB │ gzip: 0.10 kB │ map: 0.10 kB../MyApplication/entry/src/main/ets/index.scss.xss.js 0.10 kB │ gzip: 0.10 kB │ map: 0.10 kB../MyApplication/entry/src/main/ets/app_comp.js 0.27 kB │ gzip: 0.21 kB │ map: 0.70 kB../MyApplication/entry/src/main/ets/pages/index/index_taro_comp.js 0.40 kB │ gzip: 0.27 kB │ map: 0.11 kB../MyApplication/entry/src/main/ets/app_taro_comp.js 0.83 kB │ gzip: 0.46 kB │ map: 0.13 kB../MyApplication/entry/src/main/ets/pages/index/index_comp.js 0.89 kB │ gzip: 0.42 kB │ map: 0.99 kB../MyApplication/entry/src/main/ets/app.ets 2.21 kB │ gzip: 0.86 kB../MyApplication/entry/src/main/ets/render.ets 5.76 kB │ gzip: 1.23 kB../MyApplication/entry/src/main/ets/pages/index/index.ets 9.04 kB │ gzip: 2.44 kBbuilt in 2489ms.

Taro 会将编译好的文献输出至鸿蒙神色目次

运行鸿蒙

设置哄骗签名

绽开 File -> Project Structure..., 点击 Siging Configs, Sign In, 举例华为账号,点击右下角 Apply, OK, 完成签名

运行

在 DevEcho 中,点击运行按钮,待完结台扩充完成,查抄建造上,页面中将输出以下试验

```bash 首页

Hello world! ```

防御事项

通顺 Taro 时报错 throw new Error(不存在编译平台 ${platform}),config/index.ts文献中莫得添加 @tarojs/plugin-platform-harmony-ets

参考尊府

鸿蒙 & OpenHarmony🦄开云彩票(中国)官方网站



相关资讯
热点资讯
  • 友情链接:

Powered by 开云彩票(中国)官方网站 @2013-2022 RSS地图 HTML地图