Blogger Information
Blog 250
fans 3
comment 0
visits 321665
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Vue自学:v-model结合checkbox类型使用
梁凯达的博客
Original
1306 people have browsed it
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <script src="https://cdn.jsdelivr.net/npm/vue@2.6.12"></script>
  8. <title>Vue自学:v-model结合checkbox类型使用</title>
  9. </head>
  10. <body>
  11. <!-- 案例一:勾选已阅读才能进入下一步 -->
  12. <div id="app">
  13. <label for="agree">
  14. <input type="checkbox" name="agree" id="agree" value="同意" v-model="isCheckbox" />同意
  15. </label>
  16. <label for="disagree">
  17. <input type="checkbox" name="disagree" id="disagree" value="不同意"/>不同意
  18. </label>
  19. <button type="button" v-bind:disabled="!isCheckbox">提交注册</button>
  20. </div>
  21. <!-- 案例二:多选框点击存入数组中 -->
  22. <div id="app1">
  23. <label for="">
  24. <input type="checkbox" value="电影" id="movie" v-model="isCheckArray">电影
  25. <input type="checkbox" value="读书" id="read" v-model="isCheckArray">读书
  26. <input type="checkbox" value="运动" id="movement" v-model="isCheckArray">运动
  27. <input type="checkbox" value="上网" id="surf" v-model="isCheckArray">上网
  28. <h3>存入数组中...{{isCheckArray}}</h3>
  29. </label>
  30. </div>
  31. </body>
  32. <script type="text/javascript">
  33. const app = new Vue({
  34. el:'#app',
  35. data:{
  36. isCheckbox:false,
  37. },
  38. methods:{
  39. }
  40. })
  41. const app1 = new Vue({
  42. el:'#app1',
  43. data:{
  44. isCheckArray:[]
  45. },
  46. methods:{
  47. }
  48. })
  49. </script>
  50. </html>
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