[英]copying properties from json object to this scope
我们可以使用扩展运算符重写此代码还是以其他方式简化代码?
this.activeCategory = json.activeCategory
this.activeParent = json.activeParent
this.openMenu = json.openMenu
this.showMobile = json.showMobile
我在vue's mounted
钩中使用它
您可以使用与Object.assign
配对的散布运算符
const temp = { activeCategory, activeParent, openMenu, showMobile } = json;
Object.assign(this, temp);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.