<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <!-- v-model与input中的value值绑定 -->
    <input type="checkbox" name="apple" id="apple" value="apple1" v-model="names">
    <label for="apple">apple</label>
    <br>
    <input type="checkbox" name="banana" id="banana" value="banana" v-model="names">
    <label for="banana">banana</label>
    <br>
    <input type="checkbox" name="orange" id="orange" value="orange" v-model="names">
    <label for="orange">orange</label>
    <br>
    <p>{{ names }}</p>
  </div>
  <script src="node_modules/vue/dist/vue.js"></script>
  <script>
    new Vue({
      el: '#app',
      data() {
        return {
          names: []
        }
      }
    })
  </script>
</body>
</html>

 

 

Logo

前往低代码交流专区

更多推荐