我是纸飞机
我是纸飞机
  • 发布:2021-08-30 10:02
  • 更新:2022-05-16 13:40
  • 阅读:1107

uniapp通过npm下载的资源,在运行小程序的时候报错没有改模块怎么解决

分类:uni-app

1.通过npm下载了vue-qr插件资源之后,在h5运行正常,但是运行到小程序模拟器的时候却显示
[ pages/index/index.json 文件内容错误] pages/index/index.json: ["usingComponents"]["vue-qr"] 未找到(env: Windows,mp,1.05.2107221; lib: 2.19.2)

2.百度上查了一下,发现是需要配置easycom属性,于是找到uniapp文档看到这些配置(于是按照文档进行配置,能正常运行但是,还是一样的错误)

"easycom": {  
  "autoscan": true,  
  "custom": {  
    "^uni-(.*)": "@/components/uni-$1.vue", // 匹配components目录内的vue文件  
    "^vue-file-(.*)": "packageName/path/to/vue-file-$1.vue" // 匹配node_modules内的vue文件  
  }  
}

3.于是看到这句话(如果需要匹配node_modules内的vue文件,需要使用packageName/path/to/vue-file-$1.vue形式的匹配规则,其中packageName为安装的包名,/path/to/vue-file-$1.vue为vue文件在包内的路径。),又修改了如下几种配置

"easycom": {  
      "autoscan": true,  
      "custom": {  
        // "^vue-file-(.*)": "@/components/uni-$1.vue", // 匹配components目录内的vue文件  
        // "^u-(.*)":"@/uview-ui/components/u-$1/u-$1.vue"  
        // "^u-(.*)": "@/uview-ui/components/u-$1/u-$1.vue"  
        "^vue-(.*)":"@/node-modules/vue-qr/src/packages/vue-$1.vue" // 匹配node_modules内的vue文件  
        // "^vue-(.*)":"vue-qr/src/packages/vue-$1.vue" // 匹配node_modules内的vue文件  
      }  
    }

修改之后,运行小程序直接报错了。

我不知道是运行小程序是我的配置有问题还是说需要进行其他操作才可以正常引入。

2021-08-30 10:02 负责人:无 分享
已邀请:
1***@qq.com

1***@qq.com - it

一样 请问解决了吗

该问题目前已经被锁定, 无法添加新回复