0
問:有誰知道這個JavaScript ES6功能被稱爲什麼?這是將一個前綴應用於識別的名稱的技術。像這樣:JavaScript ES6:這個功能稱爲什麼?
var { Router,
Route,
IndexRoute,
IndexLink,
hashHistory,
Link } = ReactRouter;
這節省了我不得不寫的長代碼。例如:
我在寫這個陣營:
<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} />
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment – Mottie
這有什麼好做 「前綴」。正確的「long」語法是「ReactRouter.Route」(不是'ReactRouterRoute'),它是簡單的屬性訪問。 – Bergi
這篇文章明確地說明了如何保存輸入。即:加前綴。 也許它只是以不同的方式使用語法。 –