1. 检查 uniapp项目 的配置文件
- 项目/manifest.json文件中,检查是否配置了正确的 appid 、 pages 等信息。如果这些信息不正确,可能会导致小程序无法正常加载。
- 新项目启动时,如与开发者ID不一致,需修改AppId
流程:
① 生成 AppId 测试号 ( 正式开发与发行请使用正式 AppId ) :微信开发者工具 创建页 -> 小程序 -> 创建小程序 ( 页面为 [+] ) -> AppId -> 使用测试号 ( 生成一个新的AppId )
② 填充AppId:项目/manifest.json -> 微信小程序配置 -> 填充Appid
③ 也可以打开源码视图修改AppId
项目/manifest.json -> 源码视图 -> mp-weixin.appid -> 填充Appid
- 新项目启动时,如与开发者ID不一致,需修改AppId
2. 查看 HbuilderX 控制台 是否有错误信息
3. 确保 微信开发者工具 已正确安装
- 流程:微信开发者工具 创建页 -> 创建x小程序( 页面为 [+] ) -> 能正常打开
4. 检查 微信开发者工具 是否已开启服务端口。
- 流程:微信开发者工具 -> 安全 -> 勾选 服务端口
HbuilderX 错误提示:正在启动微信开发者工具... [微信小程序开发者工具] [error] IDE service port disabled. To use CLI Call, please enter y to confirm enabling CLI capability, or manually open IDE -> Settings -> Security Settings, and set Service Port On. [微信小程序开发者工具] For more details see: https://developers.weixin.qq.com/miniprogram/en/dev/devtools/cli.html [微信小程序开发者工具] [error] 工具的服务端口已关闭。要使用命令行调用工具,请在下方输入 y 以确认开启,或手动打开工具 -> 设置 -> 安全设置,将服务端口开启。 [微信小程序开发者工具] 详细信息: https://developers.weixin.qq.com/miniprogram/dev/devtools/cli.html
5. 检查 微信开发者工具 是否已登录。
-
流程:微信开发者工具 -> 创建页 -> 左下角头像
6. 检查 HBuilderX 的微信开发者工具路径是否匹配
-
流程:HBuilderX -> 工具 -> 设置 -> 运行配置 -> 小程序运行配置 -> 微信开发者工具路径 -> 设置为微信开发者工具的根目录