我正在使用 bootstrap-vue 表可选道具,我可以获得选定的行,但包含行的所有属性,但我只想要选定行的 id。这样做尝试了这个
getids(){
for (var i = 0; i <= this.selected.length; i++) {
this.filteredORD_NO.push(this.selected[i].id)
} }
其中 selected [] 是包含行的所有属性的选定数组,filteredORD_NO[] 是一个包含从选定 [] 数组中提取的 id 的数组。当我通过 btn 直接调用该函数时,这确实有效,但是当我尝试将此数据发送到后端时,显示“v-on 处理程序中的错误:“TypeError:无法读取未定义的属性 'id'”。
assignmethod() {
this.getids(),
this.WorkToteam[0] = this.filteredORD_NO,
this.WorkToteam[1] = this.selectedteam,
console.log(WorkToteam);
this.axios({
method: "POST",
url: "/path/to/backend",
data: this.workToteam,
headers: { Authorization: "Bearer " + localStorage.getItem("ikey") },
})
.then(
(response) => (
console.log("response"),
)
)
.catch((error) => console.log(error))
.finally(() => (this.loading = false));
},