我们可以使用扩展运算符重写此代码还是以其他方式简化?
this.activeCategory = json.activeCategory
this.activeParent = json.activeParent
this.openMenu = json.openMenu
this.showMobile = json.showMobile
我在vue's mounted
hook
答案 0 :(得分:1)
您可以使用与Object.assign
const temp = { activeCategory, activeParent, openMenu, showMobile } = json;
Object.assign(this, temp);