http://people.cs.nctu.edu.tw/~chaohs1031/
- 開新專案
npx create-react-app nctu_course
cd nctu_course
npm start
- 可以在 http://localhost:3000 看到初始頁面
- 安裝套件
npm install react-router-dom --save
- 設定URL
<BrowserRouter> {/* page routes */} <Switch> <Route exact path='/' component={Home} /> <Route path='/search' component={PageSearch} /> {/* 404 not found */} <Route component={NotFound} /> </Switch> </BrowserRouter>
npm install react-bootstrap --save
- 引入css到 public/index.html:
<!-- Latest compiled and minified CSS --> <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css">
- 開發文件: https://react-bootstrap.github.io/layout/grid/
- Grid System: https://getbootstrap.com/docs/3.3/css/
- 創建 mystyle.css
- 在要引用的js檔
import './XXX/mystyle.css'
fetch("http://hschao.nctu.me/courses/search_api?search=游逸平")
.then(response => response.json())
.then(json => console.log(json))
npm run build
- build/* 放入server根目錄
- 設定server root:
package.json加入:
"homepage" : "http://people.cs.nctu.edu.tw/~XXXX/"
- 修改Router Path:
path={`${process.env.PUBLIC_URL}/search`}