如题,购物车多选,怎样拿到被选到的项的id(框架为vue+element):
首先,在data里定义两个量,如代码注释,具体可参考官方文档
data() {
return {
currPage: 1,
pageSize: 8,
value1: "", //发送者
value2: "", //接收者
clearmsgVisible: false,
total: 0,
refresh: true,
mesId: "",
tableData: [],
multipleSelection: [], //定义的第一个量
selectedID: "" //定义的第二个量
};
}
然后,methods里面写如下函数:
handleSelectionChange(val) {
this.multipleSelection = val;
this.selectedID = "";
this.multipleSelection.filter(item => {
this.selectedID += item.mesId + ",";
});
this.selectedID = this.selectedID.slice(0, -1);
}
可以将this.selectedID打出来看一下,就是所有被选中的id