學(xué)習(xí)ReactNative筆記三 __React基礎(chǔ)
★★★筆記時(shí)間- 2017-1-11 ★★★
1.安裝React
安裝前的準(zhǔn)備羊始,原本是放在后面的懒鉴,但是怕誤導(dǎo)別人所以提到前面了咒唆。
如果上面的沒(méi)有報(bào)錯(cuò)了,但是目錄是空的話(huà)棚唆,請(qǐng)創(chuàng)建jspm項(xiàng)目
操作如下:
//1. 創(chuàng)建package.json
npm init
//2. 本地安裝jspm
npm install jspm --save-dev
//3.創(chuàng)建config.js
jspm init
//4.安裝包
jspm install npm:underscore
//5.安裝jquery
jspm install jquery
React Native中文官網(wǎng)
1.1 jspm install react@0.14.0-rc1
安裝React的版本;如果指定版本不對(duì)的話(huà)就生巡,直接下載最新的包: jspm install react
1.2 jspm install react-dom@0.14.0-rc1
安裝react-dom的版本,同上:jspm install react
1.3 jspm install semantic-ui
UI樣式
1.4 jspm install css
UI插件
1.5 browser-sync start --server --no-notify --files 'index.html, app/**/*.js'
創(chuàng)建一個(gè)服務(wù)器來(lái)監(jiān)視文件的變化
1.6 npm install webpack -g
安裝webpack
1.6 npm install -g webpack webpack-dev-server
webpack服務(wù)
執(zhí)行:sudo npm i babel-runtime@6 --save-dev
ERROR:
sudo npm i babel-runtime@5 --save-dev
core-js@2.4.1 node_modules/babel-runtime/node_modules/core-js -> node_modules/systemjs-builder/node_modules/core-js
/Users/x
├── UNMET PEER DEPENDENCY extraneous error: ENOENT: no such file or directory, open '/Users/x/node_modules/babel-core/package.json
├── babel-runtime@5.8.38
└── UNMET PEER DEPENDENCY webpack@1 || 2 || ^2.1.0-beta || ^2.2.0-rc
npm WARN enoent ENOENT: no such file or directory, open '/Users/x/node_modules/babel-core/package.json'
npm WARN babel-loader@6.2.10 requires a peer of babel-core@^6.0.0 but none was installed.
npm WARN babel-loader@6.2.10 requires a peer of webpack@1 || 2 || ^2.1.0-beta || ^2.2.0-rc but none was installed.
npm WARN x No description
npm WARN x No repository field.
npm WARN x No license field.
npm ERR! Darwin 16.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "i" "babel-runtime@5" "--save-dev"
npm ERR! node v6.2.0
解決的方法是:rm -rf node_modules/
,然后就可以了
重新安裝就好了:
? ~ sudo npm i babel-runtime@6 --save-dev
/Users/x
└─┬ babel-runtime@6.20.0
├── core-js@2.4.1
└── regenerator-runtime@0.10.1
npm WARN x No description
npm WARN x No repository field.
npm WARN x No license field.
安裝UI樣式:
? ~ jspm install semantic-ui
warn Running jspm globally, it is advisable to locally install jspm via npm install jspm --save-dev.
Updating registry cache...
Looking up github:Semantic-Org/Semantic-UI
Looking up npm:jquery
Looking up github:systemjs/plugin-css
ok Up to date - semantic-ui as github:Semantic-Org/Semantic-UI@^2.2.7 (2.2.7)
ok Install tree has no forks.
ok Install complete.
? ~ jspm install css
warn Running jspm globally, it is advisable to locally install jspm via npm install jspm --save-dev.
Updating registry cache...
Looking up github:systemjs/plugin-css
ok Up to date - css as github:systemjs/plugin-css@^0.1.32 (0.1.32)
ok Install tree has no forks.
ok Install complete.
npm ERR! Darwin 16.3.0
一直出錯(cuò)的原因是網(wǎng)絡(luò)超時(shí),墻一下就好了
2.定義組件
最外面的組件是:CommentBox
評(píng)論的列表:CommentList
評(píng)論的內(nèi)容顯示:Comment
評(píng)論的內(nèi)容表單:CommentForm