JavaScript ES6:这个功能叫什么?

时间:2017-05-06 16:33:55

标签: javascript ecmascript-6

问:有谁知道这个JavaScript ES6的功能是什么?这是一种将前缀应用于已识别名称的技术。像这样:

var { Router,
Route,
IndexRoute,
IndexLink,
hashHistory,
Link } = ReactRouter;

它使我不得不编写长代码。例如:

我可以在React中写这个:

<Route path="/acc"          component={CLAccounts} />
<Route path="/acc/:year"        component={CLAccounts} />
<Route path="/acc/:year/:month"     component={CLAccounts} />

而不是:

<ReactRouterRoute path="/acc"           component={CLAccounts} />
<ReactRouterRoute path="/acc/:year"     component={CLAccounts} />
<ReactRouterRoute path="/acc/:year/:month"  component={CLAccounts} />

1 个答案:

答案 0 :(得分:0)

这称为解构。这超级有用!!

了解更多here