天天看點

《React官方文檔》之Getting Started

開始react最簡單的方法就是遵循jsfiddle的hello world例子:

<a href="https://jsfiddle.net/reactjs/69z2wepo/">react jsfiddle</a>

<a href="https://jsfiddle.net/reactjs/5vjqabv3/">react jsfiddle without jsx</a>

如果你剛剛起步,你可以下載下傳starter kit。starter kit包含為浏覽器預制的react和react dom,以及幫助你開始的示例。

<a href="http://facebook.github.io/react/downloads/react-15.1.0.zip">下載下傳 starter kit 15.1.0</a>

在starter kit的根目錄下建立一個 <code>helloworld.html内容如下:</code>

你的react jsx代碼可以在一個獨立的檔案中。建立如下的 <code>src/helloworld.js</code>

然後從<code>helloworld.html引用它</code>:

注意到一些浏覽器(比如chrome)将會加載失敗除非它通過http服務.

繼續閱讀