webpack
配置模板:
(x补)
配置参考:https://github.com/luckykun/About-React
问题总结:
如果在 webpack.config.js 里有
externals: {"react": 'React', "react-dom": 'ReactDOM' }(同时需在 index.html 引入 react/react-dom.js;)
则component 里 App.js 就不能引入react了 :
import React from 'react';/import ReactDOM from 'react-dom';
否则会出现 两个react冲突报错的情况;
两种设置,只能选其一:
1. 直接在App.js { import React from 'react';/import ReactDOM from 'react-dom';}
2. webpack.config.js 设置 externals: {"react": 'React', "react-dom": 'ReactDOM' } + index.html 引入 react/react-dom.js