2016-03-08 366 views

回答

8

不能使用進口或者需要JSBin。您需要在您的html文件的head中的應用程序中使用的庫的捆綁的.js文件,然後使用稍微不同的語法來訪問添加的庫中的組件或函數。

例如,在用筆用react-router,你應該在HTML頁面的head添加它承載您的應用程序:

<script src="https://cdnjs.cloudflare.com/ajax/libs/react-router/2.0.0/ReactRouter.min.js"></script> 

之後,您的應用程序的源代碼:

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

而不是

import { Router, Route, IndexRoute, hashHistory, Link } from "react-router"; 

我克隆並更新了你的JSBin with these changes

大多數模塊.js文件的一個很好的來源是https://cdnjs.com/

相關問題