File tree Expand file tree Collapse file tree 1 file changed +75
-0
lines changed Expand file tree Collapse file tree 1 file changed +75
-0
lines changed Original file line number Diff line number Diff line change @@ -753,6 +753,81 @@ $ npx taro build --type harmony-hybrid
753753
754754- 把 Taro 项目目录下的 ` dist ` 目录的编译产物复制到鸿蒙应用的 ` src/main/resources/rawfile ` 目录下,编译运行鸿蒙应用进行开发调试。
755755
756+ ### ASCF元服务
757+
758+ 若需将 Taro 代码编译为 ASCF 元服务,需在编译命令中指定平台参数为 ` ascf ` ,并确保满足以下条件:
759+ - 代码中需包含 ASCF 元服务编译条件:` "ascf" ` (需在项目配置中声明)。
760+ - 配置文件 ` project.ascf.json ` 需存在于项目根目录。
761+
762+ 示例命令:
763+ ``` bash
764+ taro build --type ascf
765+
766+ # ### 编译命令
767+
768+ # pnpm
769+ $ pnpm dev:ascf
770+ $ pnpm build:ascf
771+
772+ # yarn
773+ $ yarn dev:ascf
774+ $ yarn build:ascf
775+
776+ # npm script
777+ $ npm run dev:ascf
778+ $ npm run build:ascf
779+
780+ # 仅限全局安装
781+ $ taro build --type ascf --watch
782+ $ taro build --type ascf
783+
784+ # npx 用户也可以使用
785+ $ npx taro build --type ascf --watch
786+ $ npx taro build --type ascf
787+
788+ # watch 同时开启压缩
789+ $ set NODE_ENV=production && taro build --type ascf --watch # CMD
790+ $ NODE_ENV=production taro build --type ascf --watch # Bash
791+
792+ 开发者工具
793+
794+ 工具准备:
795+ 下载并安装 鸿蒙开发者工具,确保已配置ASCF元服务开发环境。
796+ 导入项目:
797+ 打开鸿蒙开发者工具,选择 导入项目。
798+ 选择项目根目录下的 dist/ascf 目录(需确保已通过编译命令生成)。
799+ 配置校验:
800+ 确认项目中存在 project.ascf.json 文件(元服务专属配置)。
801+ 检查配置文件字段是否符合规范(如 minPlatformVersion、permissions 等)。
802+ 注意事项
803+
804+ 在开发者工具中需设置:
805+
806+ 关闭 ES6 转 ES5 功能(开启可能导致语法错误)。
807+ 关闭 上传代码时样式自动补全(开启可能引发样式异常)。
808+ 关闭 代码压缩上传(开启可能影响调试信息)。
809+
810+ 格式说明
811+
812+ 编译命令:
813+ 使用 --type ascf 指定平台类型,与其他小程序(如 --type weapp)格式统一。
814+ 支持 dev:ascf(开发模式)和 build:ascf(生产模式)。
815+ 开发者工具:
816+ 明确指向编译后的 dist/ascf 目录,与微信小程序的 dist 目录逻辑一致。
817+ 强调 project.ascf.json 为必需配置文件(类比 project.swan.json)。
818+ 注意事项:
819+ 与其他小程序保持完全一致的关闭选项,避免开发者混淆。
820+
821+ 效果验证
822+
823+ 执行编译命令后,检查 dist/ascf 目录是否包含以下文件:
824+ manifest.json(元服务描述文件)
825+ 页面代码及资源文件
826+ 在鸿蒙开发者工具中运行项目,确保:
827+ 页面渲染正常,无白屏或报错。
828+ 声明的权限(如定位、相机)可正常触发弹窗申请。
829+
830+
756831# # 渐进式入门教程
757832
758833我们提供了一个由浅入深的实战教程,请参考[《教程》](./guide)。
You can’t perform that action at this time.
0 commit comments