vue v-model结合checkbox

<!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="checkbox" name="" id="" value="苹果" v-model="fruit" />
      <input type="checkbox" name="" id="" value="桃" v-model="fruit" />
      <input type="checkbox" name="" id="" value="香蕉" v-model="fruit" />
      <p>{{ fruit }}</p>
    </div>

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

原文地址:https://www.cnblogs.com/zhangxuechao/p/14972575.html