表单单选按钮.html 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. <h3>选择性别</h3>
  13. <input type="radio" id="male" value="男" v-model="pickedSex">
  14. <label for="male">男</label>
  15. <br>
  16. <input type="radio" id="female" value="女" v-model="pickedSex">
  17. <label for="female">女</label>
  18. <h3>选择爱好</h3>
  19. <input type="radio" id="game" value="玩游戏" v-model="pickedHobby">
  20. <label for="game">玩游戏</label>
  21. <br>
  22. <input type="radio" id="movie" value="看电影" v-model="pickedHobby">
  23. <label for="movie">看电影</label>
  24. <h3>选择结果</h3>
  25. <p>性别: {{ pickedSex }}</p>
  26. <p>爱好: {{ pickedHobby }}</p>
  27. </div>
  28. <script>
  29. var myApp = new Vue({
  30. el: '#myApp',
  31. data: {
  32. pickedSex: "",
  33. pickedHobby: "",
  34. },
  35. methods: {},
  36. });
  37. </script>
  38. </body>
  39. </html>