如图:
现在选中两行数据后能获取到他们的name属性,怎么在点击“确定”按钮后把这两个值传到另一个页面去?
以下是部分代码:
<template>
<div>
<el-table
ref="multipleTable"
:data="users"
@selection-change="handleSelectionChange">
<el-table-column
type="selection"
width="55">
</el-table-column>
<el-table-column
prop="id"
label="编号">
</el-table-column>
<el-table-column
prop="name"
label="姓名">
</el-table-column>
<el-table-column
prop="age"
label="年龄">
</el-table-column>
</el-table>
<el-button type="primary" @click="submit">确定</el-button>
</div>
</template>
<script>
export default {
name:'User',
data() {
return{
users:[],
}
},
methods: {
handleSelectionChange(val) {
this.multipleSelection = [];
for(let i = 0; i < val.length;i++){
if(this.multipleSelection.indexOf(val[i].id)=== -1){
this.multipleSelection.push(val[i].name)
}
}
// this.multipleSelection = val
console.log(this.multipleSelection);
},
submit(){
},
},
}
</script>