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组件,编译后点击进入插件页面时提示Component is not found in path

"plugin-private://xxxxxxxxx/..npm/taro-ui/dist/weapp/components/button/index"

复现步骤

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

"plugin-private://xxxxxxxxx/..npm/taro-ui/dist/weapp/components/button/index"

/**

* 这段注释后可以贴代码

* 提供完整可复现的代码和整理好代码格式,有助于我们快速定位问题,节省你我时间

* 代码提供不全或代码格式混乱的 issues 【有可能会被忽略】

*

* 查看如何插入代码:https://coding.net/help/doc/project/markdown.html#i-5

*/

期望行为

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

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

报错信息

SystemError (jsEnginScriptError)

Component is not found in path "plugin-private://xxxxxxxxx/..npm/taro-ui/dist/weapp/components/button/index" (using by "plugin-private://xxxxxxxxx/pages/list/list")

Error: Component is not found in path "plugin-private://xxxxxxxxx/..npm/taro-ui/dist/weapp/components/button/index" (using by "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 社区」一起交流

你可能感兴趣的:(taro,引入js)