实现代码:
demo全选:
{{checked}}
多个复选框:
uuihoo
taobao
选择的值为:{{checkedNames}}
new Vue({
el: '#app',
data: {
checked: false,
checkedNames: [],
checkedArr: ["uuihoo", "alibaba", "Google"]
},
methods: {
changeAllChecked: function() {
if (this.checked) {
this.checkedNames = this.checkedArr
} else {
this.checkedNames = []
}
}
},
watch: {
"checkedNames": function() {
if (this.checkedNames.length != this.checkedArr.length) {
this.checked = false
} else {
this.checked = true
}
}
}
})
实现效果图:
本文来源于网络:查看 >https://blog.csdn.net/uuihoo/article/details/79569605