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