vue3+ts+vite+element plus 实现table勾选、点击单行都能实现多选

需求:table的多选栏太小,点击的时候要瞄着点,不然选不上,要求实现点击单行实现勾选


				
				
				
			

const weightList = ref([])
const handleSelectionChange = (val: any) => {
	weightList.value = val
	console.log(weightList)
}

const handleRowChick = (row) => {
	const selected = weightList.value.some(
		(item) => item.variableName === row.variableName
	)
	if (!selected) {
		weightList.value.push(row)
		multipleTableRef.value.toggleRowSelection(row)
	} else {
		const weightListNew = weightList.value.filter((item) => {
			return item.variableName !== row.variableName
		})
		weightList.value = weightListNew
		multipleTableRef.value.toggleRowSelection(row, false)
	}
}

你可能感兴趣的:(vue.js,javascript,elementui)