外部样式类用法:
一.自定义子组件:
1. tag/index.wxml:
在class类名里写入需要的外部样式类
<view class="tag-class"></view>
2.tag/index.js
Component({
externalClasses:['tag-class']
})
二.页面上引入组件
1.detail.json:
"usingComponents":{
"tag-cmp": "/components/tag/index",
}
2.detail.wxml
在父组件的标签上写入子组件externalClasses配置项传入的值作为css的class类名称
<tag-cmp tag-class="tag"></tag-cmp>
3.detail.wxss
.tag {
margin-right: 15rpx;
margin-bottom: 10rpx;
border-radius: 15px !important;
}