是 v-model 和value 一起,多个勾选框都绑定到同 个数组类型的数据
过程也是双向的,在勾选时, value 的值也会自动 push这个数组中
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="app">
兴趣:<input type="checkbox" v-model="interest" value='run' id="run"><label for="run">跑步</label>
<input type="checkbox" v-model="interest" value="swimming" id="swimming"><label for="swimming">游泳</label>
<input type="checkbox" v-model="interest" value="pingpang" id="pingpang"><label for="pingpang">乒乓</label>
<br/>
<span>{{interest}}</span>
</div>
<script>
var v=new Vue({
el:"#app",
data:{
interest:[]
}
})
</script>
</body>
</html>