使用 npm start命令运行正常,使用npm run build执行会报错如下:
syntax error: C:/Users/wenji/Desktop/my-react-app/src/index.js:
Unexpected token (26:6)
我的index.js:
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import registerServiceWorker from './registerServiceWorker';
import './App.css';
import Chat from './chat/index';
import Login from './login/index'
import {
BrowserRouter as Router,
Route,
Switch
} from 'react-router-dom';
import { Provider} from 'react-redux'
import store from './store'
// const Home = () => (
// <div>
// <h3>Home</h3>
// </div>
// )
class App extends Component{
render(){
console.log(Router)
return (
<Router >
<div style={{height:'100%'}}>
<Switch>
<Route exact path="/" component={Login}/>
<Route path="/chat" component={Chat}/>
{/* <Route path="/home" component={Home}/> */}
<Route path="/login" component={Login}/>
</Switch>
</div>
</Router>)
}
}
ReactDOM.render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('root'));
registerServiceWorker();
看起来像是jsx语法没有被正确的转化,我的webpack.config.build是这样的
慕工程0101907
慕的地10843
相关分类