Advertisement

taro 引入js_小程序插件运行及引入taro-ui等第三方组件库报错

阅读量:

问题描述

v2.2.8和v2.2.9都存在以下问题

问题1:运行报错

通过小程序插件命令完成编译后,在微信开发者工具中打开显示提示信息 plugin.json 文件

在编译时遵循文件目录层级结构配置project.config.json中的'pluginRoot'字段为'plugin/’。

修改为"pluginRoot": "miniprogram/miniprogram/plugin/"

问题2:引入taro-ui等第三方插件报错

以Taro UI为例,在项目初始化完成后,在plugin目录中导入Taro UI组件,并经过编译之后访问该组件所在的页面时会收到提示信息:该组件未找到指定路径。

protocol-private://.dot-npm-array/.dot-npm-array/taro-ui.dist.weapp/components/button/index.html5-appletag-1.2.3

复现步骤

taro init 选择 wxplugin

在src/plugin/pages/list/list.tsx使用taro-ui AtButton组件

运行编译指令 taro build --plugin weapp --watch

在页面上点击Go to pages/list!

提示Component is not found in path

私有插件位于taro-ui的应用目录下的dist文件夹中找到我们app的组件文件夹中的交互按钮组件

/**

  • 这段注释后可以贴代码

分享能够方便复制使用的代码,并且规范地排列代码结构,将帮助我们迅速识别并解决问题,减少工作负担。

*/

期望行为

调整plugin的编译生成目录,与project.config.json中保持一致

引入第三方组件使用正常,不报错

报错信息

SystemError (jsEnginScriptError)

The component cannot be located within the specified path 'plugin-private://xxxxxxxxx/..npm/taro-ui/dist/weapp/components/button/index' (using the plugin 'plugin-private://xxxxxxxxx/pages/list/list').

错误提示:该组件未找到位于路径 "plugin-private://xxxxxxxxx/..npm/taro-ui/dist/weapp/components/button/index"(使用 'plugin-private://xxxxxxxxx/pages/list/list')

at e (http://127.0.0.1:64000/appservice/dev/WAService.js:2:1872190)

at e (http://127.0.0.1:64000/appservice/dev/WAService.js:2:1872391)

at http://127.0.0.1:64000/appservice/dev/WAService.js:2:1896007

at Module._t (http://127.0.0.1:64000/appservice/dev/WAService.js:2:1896569)

at Function.value (http://127.0.0.1:64000/appservice/dev/WAService.js:2:1988290)

at jt (http://127.0.0.1:64000/appservice/dev/WAService.js:2:2004560)

at Mt (http://127.0.0.1:64000/appservice/dev/WAService.js:2:2007490)

at Function. (http://127.0.0.1:64000/appservice/dev/WAService.js:2:2017970)

at i. (http://127.0.0.1:64000/appservice/dev/WAService.js:2:1980628)

at i.emit (http://127.0.0.1:64000/appservice/dev/WAService.js:2:655930)

系统信息

Taro CLI 2.2.9 environment info:

System:

OS: Windows 10

Binaries:

Node: 14.4.0 - C:\soft\nodejs\node.EXE

Yarn: 1.22.4 - E:\node Files\node_global\yarn.CMD

npm: 6.14.5 - C:\soft\nodejs\npm.CMD

补充信息

如果您有功能上的建议,可以提到 FeatHub

使用上的问题,欢迎在「Taro 社区」一起交流

全部评论 (0)

还没有任何评论哟~