1 回答

TA貢獻(xiàn)1809條經(jīng)驗(yàn) 獲得超8個(gè)贊
問(wèn)題是您將設(shè)置editedItem.school為array而不是string,因此它會(huì)抱怨您不能設(shè)置split()數(shù)組。
當(dāng)您設(shè)置 時(shí)editedItem.school,您應(yīng)該通過(guò) 將其轉(zhuǎn)換回字符串Array.join(",")。
export default {
data: () => ({
schools: ["Schools 1", "Schools 2", "Schools 3"],
editedItem: {...}
}),
computed: {
schoolArray: {
get: function() {
return this.editedItem.school.slice(0).split(",");
},
set: function(school) {
// set it back to a string using `join(",")`
this.editedItem.school = school.join(",");
}
}
}
}
添加回答
舉報(bào)