小程序自定义插件组成结构如下
暴露的public-components中有一个组件,例如 ComA
comA中使用了另两个组件,comB和comC
在小程序中引入插件使用comA
发现comA中的comB和comC的样式丢失
如果插件中直接暴露comB或者comC
在小程序中引入插件使用comB或者comC
comB的样式正常
预期无论comA还是comB或者comC都应该样式正常
======================== 插件部分 ========================
plugin.json
{ "publicComponents": { "list": "components/list/list" }, "main": "index.js"} |
---|
组件 list.wxml
<view> <item /></view> |
---|
组件list.json
{ "component": true, "usingComponents": { "item": "./item" }} |
---|
组件 Item.wxml
<!--plugin/components/list/item.wxml--><text class="haha">plugin/components/list/item.wxml</text> |
---|
组件 item.wxss
/* plugin/components/list/item.wxss */ .haha { background-color: red; color: #fff;} |
---|
======================== 使用插件的小程序部分 ========================
小程序 app.js
{ "pages": [ "pages/index/index" ], "plugins": { "myPlugin": { "version": "dev", "provider": "touristappid" } }} |
---|
小程序 index.wxml
<!-- <checkin-picker /> --> <list /> |
---|
小程序 Index.json
{ "usingComponents": { "list": "plugin://myPlugin/list", }} |
---|
小程序输入结果
可以看到 item组件中的文字颜色和背景全部丢失
==========================
如果我修改 插件的Plugin.json为
{ "publicComponents": { "list": "components/list/item", }, "main": "index.js"} |
---|
也就是直接暴露 Item这个组件,预览一下
可以看到item的背景颜色和文字颜色样式正常。。
这不是bug么?
=================
以上都是在新建插件项目模板的基础上改的,而且即使是插件模板项目,console中也一直报这些错误
不知道什么原因
相似问题