v-model值绑定,利用v-for循环
v-for循环,绑定v-model
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="app">
{{message}}
<label v-for="item in hobbys" :for="item">
<input type="checkbox" :value="item" v-model="hobb" :id="item">{{item}}
</label>
<h2>选择的是:{{hobb}}</h2>
</div>
<script src="../vue.js"></script>
<script>
const app = new Vue({
el: '#app',
data: {
message: 'hello',
hobbys: ['足球','蓝旗','排球','乒乓球'],
hobb: []
}
})
</script>
</body>
</html>