使用自定义组件,在H5可以正常显示,编译到小程序时组件的样式都没有了。wxss文件里有,但是选中组件查看样式,没有组件样式文件里定义的内容。
pages.json里加了usingComponents了
"globalStyle": {
"usingComponents": {
// #ifdef APP-PLUS || MP-WEIXIN || MP-QQ
"float-btn": "/wxcomponents/floatBtn/index"
// #endif
}
}
组件样式加了scoped了
<style lang="less" scoped>
#float_btn {
width: 1.16rem;
height: 2.32rem;
position: absolute;
bottom: 2.5rem;
right: 0.06rem;
z-index: 9;
img {
width: 1.16rem;
height: 1.16rem;
}
touch-action: none;
}
</style>
页面里这样使用
<float-btn class="floatBtn" ></float-btn>
运行到小程的时候,选中自定义组件,没有看到设置的样式
但是编译好的小程序文件中,组件的样式文件里可以看到