<div id="app">
<van-checkbox-group v-model="test" direction="horizontal" >
<van-checkbox v-for="v in test_list " :name="v" :key="v" style="padding: 5px;" >{{v}}</van-checkbox>
</van-checkbox-group>
</div>
<script>
var app=new Vue({
el:'#app',
data:{
,test:[1,3,'4'] // 已选中值
,test_list:['1','2','3','4','5','6','7','8','9','10'] // 所有选项
}
})
// test_list 中的值类型是字符,设置已选中值 数据的类型也应该是字符
// test 选中3个,渲染后只会选中值是4的选项
// this.test[0]=this.test[0].toString(); 整型转字符
// this.test[2]=parseInt(this.test[2]); 字符转整型
</script>
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!