一、现象
当开启懒加载按需加载模式requiredComponents时,genericsImplementation配置的路径会找不到,提示如下:
Component is not found in path "XXXXXX"
问题基础库从2.13.0开始,一直到目前的2.30.0
基础库2.12.3无此问题
app.json对应配置示例如下:
{
"pages": [
"pages/index/index"
],
"lazyCodeLoading": "requiredComponents",
"plugins": {
"data_query": {
"version": "dev",
"provider": "xxxxxxx",
"genericsImplementation": {
"item": {
"mp-view": "components/comp/comp"
}
}
}
}
}
二、解决方式
1. 【有效】关闭按需加载模式,去除"lazyCodeLoading": "requiredComponents"(此方法有悖于性能指南,等待后续官方修复)
{
"pages": [
"pages/index/index"
],
"plugins": {
"data_query": {
"version": "dev",
"provider": "xxxxxxx",
"genericsImplementation": {
"item": {
"mp-view": "components/comp/comp"
}
}
}
}
}
2. 【这个有问题】按照按需加载的原理,直接挂载组件到app上,app.json 添加 "usingComponents" 配置插件引入的组件,但会报错栈溢出 "RangeError: Maximum call stack size exceeded",具体原因待研究。
{
"pages": [
"pages/index/index"
],
"lazyCodeLoading": "requiredComponents",
"usingComponents": {
"mp-view": "components/comp/comp"
},
"plugins": {
"data_query": {
"version": "dev",
"provider": "xxxxxxx",
"genericsImplementation": {
"item": {
"mp-view": "components/comp/comp"
}
}
}
}
}
三、参考资料
可复现的代码片段:https://developers.weixin.qq.com/s/SalY1KmI7uFr
代码注入优化:https://developers.weixin.qq.com/miniprogram/dev/framework/performance/tips/start_optimizeB.html
为插件提供组件:https://developers.weixin.qq.com/miniprogram/dev/framework/plugin/using.html
插件引用小程序组件:https://developers.weixin.qq.com/miniprogram/dev/framework/plugin/development.html
我也一直有这个问题,还没解决吗
只在工具复现么
android7.1,
wmpf-service.apk版本是2.2,
awmpf-cli版本是2.2