复选框.html 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <title>复选框</title>
  5. <meta charset="UTF-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <script src="https://unpkg.com/vue/dist/vue.js"></script>
  8. <link href="../css/style.css" rel="stylesheet"> </head>
  9. <body>
  10. <div id="myApp">
  11. <h1>表单复选框</h1>
  12. <input type="checkbox" id="生化危机7" value="生化危机7" v-model="checkedGames">
  13. <label for="生化危机7">生化危机7</label>
  14. <input type="checkbox" id="模拟飞行" value="模拟飞行" v-model="checkedGames">
  15. <label for="模拟飞行">模拟飞行</label>
  16. <input type="checkbox" id="塞尔达传说" value="塞尔达传说" v-model="checkedGames">
  17. <label for="塞尔达传说">塞尔达传说</label>
  18. <br>
  19. <p>您选择的游戏是:</p>
  20. <p v-for="game in checkedGames"> {{ game }} </p>
  21. </div>
  22. <script>
  23. var myApp = new Vue({
  24. el: '#myApp',
  25. data: {
  26. checkedGames: []
  27. },
  28. methods: {},
  29. });
  30. </script>
  31. </body>
  32. </html>