ES6新增语法有哪些
dearweb 发布:2021-10-09 17:18:36阅读:箭头函数
Arrow functions: <C onPress={() => this.setState({pressed: true})} />
块级作用域
Block scoping: let greeting = 'hi';
数组的扩展运算
Call spread: Math.max(...array);
类
Classes: class C extends React.Component { render() { return <View />; } }
常量
Constants: const answer = 42;
解构 Destructuring:
var {isActive, style} = this.props;
for...of:
for (var num of [1, 2, 3]) {}
模块 Modules:
import React, { Component } from 'react';
动态属性键 Computed Properties:
var key = 'abc'; var obj = {[key]: 10};
对象方法的简写 Object Consise Method:
var obj = { method() { return 10; } };
对象属性的简写 Object Short Notation:
var name = 'vjeux'; var obj = { name };
参数的扩展运算 Rest Params:
function(type, ...args) { }
字符串模板 Template Literals:
var who = 'world'; var str = `Hello ${who}`;
小礼物走一波,支持作者
赏还没有人赞赏,支持一波吧