vue 属性下划线两边如何拼接变量?
我想将this.datas中的属性mech_XXX_json.data中的两边下划线中的XX替换成newValue,如何做,麻烦懂的大佬指导一下
afterLeaveTab: {
handler(newValue, oldValue) { this.gathers.forEach(item => {
if (newValue == item.key) {
this.tableData = this.datas.mech_${newValue}_json.data
}
})
}
回答:
const key = `mech_${newValue}_json`this.tableData = this.datas[key].data
以上是 vue 属性下划线两边如何拼接变量? 的全部内容, 来源链接: utcz.com/p/933409.html