label绑定数据

查看实例:

  1. <html>  
  2. <head>  
  3. <title>test</title>  
  4. <meta http-equiv="content-Type" content="text/html;charset=utf-8">  
  5. </head>  
  6. <body>  
  7. <form>  
  8.   
  9. //第一种:  
  10. //文字必须是label标签内,checkbox的id和<label>标签内的for=""中的名字必须相同.  
  11. <input type="checkbox" id="check1" value="go" name="name">  
  12. <label for="check1">姓名</label
  13. <input type="checkbox" id="check2" value="on" name="name">  
  14.  <label for="check2">密码</label>  
  15. //第二种:  
  16. //把文字和checkbox包含在<label>标签内  
  17. <label>测试<input type="checkbox" id="11" /></label>  
  18. </form>  
  19. </body>  
  20. </html>  

注意事项:文字必须是label标签内,checkbox的id和<label>标签内的for=""中的名字必须相同.

vue中label实现绑定:

1、多选绑定一个数组

<div id="dong">
  <span>{{message}}</span>=<span v-text="message"></span>
  <span v-html="msgHtml"></span>
  <hr>
  <p>
    <input type="checkbox" value="pp" v-model="web_names" id="one">
    <label for="one">pan</label><br/>
    <input type="checkbox" value="gg" v-model="web_names" id="twe">
    <label for="twe">gg</label><br/>
    <input type="checkbox" value="ww" v-model="web_names" id="three">
    <label for="three">ww</label><br>
    <input type="checkbox" value="vv" v-model="web_names" id="four">
    <label for="four">vgo</label>
    <p>{{web_names}}</p>
  </p>
</div>
var dong=new Vue({
  el:'#dong',
  data:{
    message:'hello vue!',
    msgHtml:'<h2>hello vue</h2>',
    web_names:[]
  }
})
2、单选绑定一个数组
原文地址:https://www.cnblogs.com/fengup/p/7440429.html