vue v-model结合radio

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
  </head>

  <body>
    <div id="app">
      <p>{{ message }}</p>
      <input type="radio" name="" id="" value="男" v-model="sex" />
      <input type="radio" name="" id="" value="女" v-model="sex" />
      <p>{{ sex }}</p>
    </div>

    <script>
      const app = new Vue({
        el: '#app',
        data: {
          message: 'Hello Vue.js!',
          sex: '男'
        },
      })
    </script>
  </body>
</html>

posted @ 2021-07-05 15:08  thomas_blog  阅读(76)  评论(0编辑  收藏  举报