checkboxGroup选择后实时传递已选择的数组

checkbox上绑定@change=“checkChange(item)”,
其中item为当前checkbox对应对象

data() {
	return {
		params: {},
		checkList: [],	//已选中数组
		sltCount: '', //已选中数组的长度
	}
}
methods: {
	checkChange(item) {
		if (item.checked) 
			this.params[item.id] = {
				id: item.id, 
				name: item.name, 
				hostPic: item.hostPic, 
			}
		else 
			delete this.params[item.id]
		this.sltCount = Object.keys(this.params).length
		this.checkList = Object.values(this.params)
	},
}
	

你可能感兴趣的:(checkboxGroup选择后实时传递已选择的数组)