Vue多个多选框使用v-model绑定一个数组
<!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, init
·
<!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>
更多推荐
已为社区贡献12条内容
所有评论(0)