學習ReactNative筆記三 __React基礎


學習ReactNative筆記三 __React基礎

★★★筆記時間- 2017-1-11 ★★★


1.安裝React

安裝前的準備,本來是放在後面的,可是怕誤導別人因此提到前面了。

若是上面的沒有報錯了,可是目錄是空的話,請建立jspm項目

操做以下:

//1. 建立package.json
npm init

//2. 本地安裝jspm
npm install jspm --save-dev

//3.建立config.js
jspm init

//4.安裝包
jspm install npm:underscore

//5.安裝jquery
jspm install jquery

React Native中文官網

1.1 jspm install react@0.14.0-rc1 安裝React的版本;若是指定版本不對的話就,直接下載最新的包: jspm install react
1.2 jspm install react-dom@0.14.0-rc1 安裝react-dom的版本,同上:jspm install react
1.3 jspm install semantic-uiUI樣式
1.4 jspm install css UI插件
1.5 browser-sync start --server --no-notify --files 'index.html, app/**/*.js'建立一個服務器來監視文件的變化
1.6 npm install webpack -g安裝webpack
1.6 npm install -g webpack webpack-dev-server webpack服務css

執行: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/,而後就能夠了

從新安裝就行了:html

➜  ~ 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樣式:node

➜  ~ 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

一直出錯的緣由是網絡超時,牆一下就行了

2.定義組件

最外面的組件是:CommentBox
評論的列表:CommentList
評論的內容顯示:Comment
評論的內容表單:CommentFormreact

3. 顯示ReactDom.render

🐼🐶🐶若是對你有幫助,或以爲能夠。請右上角star一下,這是對我一種鼓勵,讓我知道我寫的東西有人承認,我纔會後續不斷的進行完善。

有任何問題或建議請及時issues me,以便我能更快的進行更新修復。

Email: marlonxlj@163.com

相關文章
相關標籤/搜索