Blogger Information
Blog 51
fans 0
comment 1
visits 65044
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Vant 复选框组设置默认选中值无效
鱼的熊掌
Original
2945 people have browsed it
  1. <div id="app">
  2. <van-checkbox-group v-model="test" direction="horizontal" >
  3. <van-checkbox v-for="v in test_list " :name="v" :key="v" style="padding: 5px;" >{{v}}</van-checkbox>
  4. </van-checkbox-group>
  5. </div>
  1. <script>
  2. var app=new Vue({
  3. el:'#app',
  4. data:{
  5. ,test:[1,3,'4'] // 已选中值
  6. ,test_list:['1','2','3','4','5','6','7','8','9','10'] // 所有选项
  7. }
  8. })
  9. // test_list 中的值类型是字符,设置已选中值 数据的类型也应该是字符
  10. // test 选中3个,渲染后只会选中值是4的选项
  11. // this.test[0]=this.test[0].toString(); 整型转字符
  12. // this.test[2]=parseInt(this.test[2]); 字符转整型
  13. </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!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post