<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.12"></script>
<title>Vue自学:input中的值绑定</title>
</head>
<body>
<div id="app">
<label v-for="item in fruits" v-bind:for="item">
<input type="checkbox" v-bind:id="item" v-bind:value="item" v-model="resArr" />{{item}}
</label>
<h3>你选择的包括:{{resArr}}</h3>
</div>
</body>
<script type="text/javascript">
const app = new Vue({
el:’#app’,
data:{
fruits:[
‘香蕉’,
‘苹果’,
‘雪梨’,
‘哈密瓜’,
‘西红柿’
],
resArr:[]
}
})
</script>
</html>