Checkbox复选框
引入
在app.json或index.json中引入组件,默认为ES6版本
"usingComponents": {
"vtu-checkbox": "/miniprogram_npm/vtuweapp/checkbox/checkbox/vtu-checkbox",
"vtu-checkbox-prop": "/miniprogram_npm/vtuweapp/prop/checkbox/prop/vtu-checkbox-prop",
"vtu-checkbox-prop-item": "/miniprogram_npm/vtuweapp/prop/checkbox/item/vtu-checkbox-prop-item"
}
代码演示
基础用法
<vtu-checkbox-group model="{{value1}}" bind:change="change">
<vtu-checkbox value="1" label="北京"></vtu-checkbox>
<vtu-checkbox value="2" label="上海"></vtu-checkbox>
<vtu-checkbox value="3" label="深圳"></vtu-checkbox>
<vtu-checkbox value="4" label="南京"></vtu-checkbox>
</vtu-checkbox-group>
Page({
data: {
value1: ['2', '4']
},
change: function(e) {
this.setData({
value1: e.detail.value
})
}
});
自定义
<vtu-checkbox-group model="{{value1}}" align="right" active-color="red" checkbox-icon="iconfont icon-fangxingweixuanzhong" active-checkbox-icon="iconfont icon-fangxingxuanzhongfill" bind:change="change">
<vtu-checkbox value="1" label="北京"></vtu-checkbox>
<vtu-checkbox value="2" label="上海" disabled></vtu-checkbox>
<vtu-checkbox value="3" label="深圳"></vtu-checkbox>
<vtu-checkbox value="4" label="南京"></vtu-checkbox>
</vtu-checkbox-group>
自定义图标
<vtu-checkbox-group model="{{value1}}" max="{{3}}" align="right" checkbox-icon="" active-color="orange" active-checkbox-icon="iconfont icon-duihao" active-checkbox-color="blue" bind:change="change">
<vtu-checkbox value="1" label="北京" icon="iconfont icon-biaoxing" ></vtu-checkbox>
<vtu-checkbox value="2" label="上海" icon="iconfont icon-xihuan" ></vtu-checkbox>
<vtu-checkbox value="3" label="深圳" icon="iconfont icon-sousuo"></vtu-checkbox>
<vtu-checkbox value="4" label="南京" icon="iconfont icon-shangchuan"></vtu-checkbox>
</vtu-checkbox-group>
弹出复选框
<vtu-btn type="primary" bind:click="openCheckboxProp">弹出复选框</vtu-btn>
<vtu-checkbox-prop show="{{showProp}}" model="{{value1}}" max="{{3}}" align="right" checkbox-icon="" active-color="orange" active-checkbox-icon="iconfont icon-duihao" active-checkbox-color="blue" bind:change="change">
<vtu-checkbox-prop-item value="1" label="北京" icon="iconfont icon-biaoxing" ></vtu-checkbox-prop-item>
<vtu-checkbox-prop-item value="2" label="上海" icon="iconfont icon-xihuan" ></vtu-checkbox-prop-item>
<vtu-checkbox-prop-item value="3" label="深圳" icon="iconfont icon-sousuo"></vtu-checkbox-prop-item>
<vtu-checkbox-prop-item value="4" label="南京" icon="iconfont icon-shangchuan"></vtu-checkbox-prop-item>
</vtu-checkbox-prop>
Page({
data: {
value1: ['2', '4'],
showProp: false
},
change: function(e) {
this.setData({
value1: e.detail.value
})
},
openCheckboxProp: function(){
this.setData({
showProp: true
})
}
});
组件参数