Home > Web Front-end > JS Tutorial > body text

Analytical structure in Es6

PHP中文网
Release: 2017-06-22 11:36:46
Original
1357 people have browsed it

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h1>数组以序列号一一对应,这是一个有序的对应关系</h1>
<h1>而对象根据属性名一一对应,这是一个无序的对应关系</h1>
<script type="text/javascript">
// 首先有这么一个对象
const props = {
userName: &#39;button&#39;,
loading: false,
clicks: true,
disabled: &#39;disabled&#39;
}
//当我们想要取得其中的2个值:loading与clicked时:
// es5
var loading = props.loading;
var click = props.clicks;
console.log(loading)
console.log(clicks)
//es6
const { loading, clicks } = props;
// 给一个默认值,当props对象中找不到loading时,loading就等于该默认值
const { loading = false, clicks } = props;
// 比如
// section1 
import React, { Component } from &#39;react&#39;;
// section2
export { default } from &#39;./Button&#39;;
// section3
const { click, loading } = this.props;
const { isCheck } = this.state;
</script>
</body>
</html>
Copy after login


The above is the detailed content of Analytical structure in Es6. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template