郴州网站制作找工作,网页生成pdf失败,网站开发评分标准,怎么用ip地址做网站我最近在用react讨生活。我的感觉#xff0c;react开发效率不高。这当然应该是我还不熟悉react的缘故。但是#xff0c;在阅读react代码过程中#xff0c;其中一个容易困惑的地方是它到处充斥着的解构赋值。当然了#xff0c;解构赋值并不是React特有的功能#xff0c;而是…我最近在用react讨生活。我的感觉react开发效率不高。这当然应该是我还不熟悉react的缘故。但是在阅读react代码过程中其中一个容易困惑的地方是它到处充斥着的解构赋值。当然了解构赋值并不是React特有的功能而是ES6ECMAScript 2015引入到JavaScript中的语言特性。但react中泛滥成灾是普遍现象。
据说解构赋值简化了语言使得代码更具可读性云云。不敢苟同。比如下面这个
render() {const {sysUser: { data, roleSelectData, orgTreeData, userType },loading,} this.props;...
}是什么意思
一句句地解构。
首先第一层
render() {const {sysUser,loading} this.props;...
}哦这是解构赋值相当于
const sysUser this.props.sysUser;
const loading this.props.loading;然后第二层相当于
const sysUser this.props.sysUser;
const loading this.props.loading;const data sysUser.data;
const roleSelectData sysUsedr.orgTreeData;
const userType sysUser.userType;但是这难道不是json对象的定义模式吗怎么在这里变成了赋值并且是将左边的东西赋给右边的只能说这种赋值忽左忽右神鬼莫测。简则简矣可读则未必。