iview table使用自定义按钮取消某个选中的单项
实现效果:
选中选项后然后弹出选中的选项框,点击删除按钮删除某一个选项,table中的选中状态也随之变化。
ivew坑:给data设置_checked其实对table上的checkBox并没有作用,用js给data数据设置该属性并没有作用,具体看这篇博客:https://blog.csdn.net/love_parents/article/details/82219503
deleteChooseGoods(id) {
this.choosedGoods.forEach((item, index) => {
if (item.id == id) {
//给table设置ref,然后加上这段代码,index是想要删除的选择项,加上这段代码则能实现弹出框删除状态与checkBox选中状态相关联的效果
this.$refs.outgoodsTable.toggleSelect(index)
this.choosedGoods.splice(index, 1)
if(this.choosedGoods.length<=0){
this.choosedGoods=[]
this.cancelAll()
this.model = false
}
}
})
},