上一篇:《远程工作日常流程》
react 项目应用原理流程
---------------------------------------------------------
package.json - server.js - webpack.dev.js - main.js - App.js
main.js 说明了所有的react元素将填充入哪个页面,哪个Dom
App.js 说明了react组件的原始位置,其他的页面等都是从App.js来的
----------------------------------------------------------
1. package.json
"start": "cross-env NODE_ENV=development node server/base.js",
2.sever/ base.js - server.js
// koa路由模块
var api = require('./controller/api');
// 开发环境启用devserver
var devConfig = require('../webpack/webpack.dev');
compile = webpack(devConfig);
3. Webpack/ Webpack.dev.js
path.resolve(__dirname, '../client/main.js')
4. Client/ main.js
import App from './components/App';
// 渲染
ReactDOM.render(
<Provider store={store}>
<App />
</Provider>
, document.getElementById('root')
);
5. Client/ components / App.js
import React, { Component } from 'react';
class App extends Component {
render() {
return (
<Router>
export default App;
下一篇:《react 必备知识点》