app.json 中声明通过 npm 安装的自定义组件,真机报错“组件路径错误”
发布于 6 年前 作者 jing06 8928 次浏览 来自 官方Issues

问题:

在 app.json 中声明通过 npm 安装的自定义组件,在开发者工具上表现正常,但在真机上会报错 Component is not found in path xxx

只有在相关页面的 json 文件中声明才没问题。

// app.json
{
  //...
    "usingComponents": {
        "applyComponent": "wx-library/components/apply/index",
        "cityComponent": "wx-library/components/city/index",
        "promptComponent": "wx-library/components/prompt/index"
    }
}

文件路径:

seo-sell
├─ miniprogram_npm
│    └─ wx-library
│           ├─ common
│           ├─ components
│           └─ index.js
├─ app.json
2 回复

工具的版本是?

使用已注册的自定义组件前,首先要在页面的 json 文件中进行引用声明。此时需要提供每个自定义组件的标签名和对应的自定义组件文件路径

https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/

回到顶部