因為國內使用npm很慢,我們可以使用**的cnpm,同時設定映象位址
安裝成功後,可以鍵入cnpm -v檢查是否安裝成功
建立react專案
解構出所有的配置檔案
yarn eject
執行react專案
打包react方法一(使用yarn) yarn start
方法二(使用npm) npm start
除錯專案的推薦給瀏覽器裝乙個外掛程式react-dev-tools,方便除錯方法一(使用yarn) yarn build
方法二(使用npm) npm run build
使用指令npm run eject
或者yarn eject
解析出config與scripts配置的資料夾,便於修改
報git錯誤時:
git add . -> git commit -m 『init』 -> yarn eject
報缺少babel 包: 安裝一下
//修改埠
//修改script/start.js
const
default_port
=parseint
(process.env.
port,10
)||3001
;//去除eslint 警告
//config/webpack.config.js
//注釋關於eslint的匯入和rules規則
, loader: require.
resolve
('eslint-loader'),
},],
}
React入門(二) React元件的生命週期
componentwillmount componentdidmount componentwillunmount componentwillupdate componentdidupdate shouldcomponentupdate componentwillreceiveprops react...
React入門教程(二)
react基礎總結 續 示例 commentbox react createclass hello,world i am a commentbox.reactdom render react createelement commentbox null document getelementbyid ...
React 高階指南小記
接上篇,還是筆記,還是乾貨。如果使用 jsx 表示式,foo必須在範圍內,因為這些標籤被編譯為對指定變數的直接引用。由於 jsx 編譯為對react.createelement 的呼叫,因此 react 庫必須始終在 jsx 的作用域中。可以使用 jsx 中的點表示法來引用 react 元件。如果有...