我用 react-redux,redux 创建了 reactjs 应用程序。启动 reactjs 项目时,在索引文件的第 13 行出现意外的令牌错误。下面给出了索引文件。
ERROR in ./src/index.js
Module build failed: SyntaxError: D:/Reactjs_work/
/src/index.js: Unexpected token (13:2)
11 |
12 | ReactDOM.render(
> 13 | <Provider store={createStoreWithMiddleware(reducers)}>
| ^
14 | <App />
15 | </Provider>
16 | , document.querySelector('.container'));
@ multi main
webpack: Failed to compile.
以下是 index.js 文件
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import App from './components/app';
import reducers from './reducers';
const createStoreWithMiddleware = applyMiddleware()(createStore);
ReactDOM.render(
<Provider store={createStoreWithMiddleware(reducers)}>
<App />
</Provider>
, document.querySelector('.container'));
我已经完成了以下主题here.but没有成功。 Reactjs:意外标记“<”错误 ReactJS 语法错误:意外标记
webpack.config.js
module.exports = {
entry: [
'./src/index.js'
],
output: {
path: __dirname,
publicPath: '/',
filename: 'bundle.js'
},
module: {
loaders: [{
exclude: /node_modules/,
loader: 'babel'
}]
},
resolve: {
extensions: ['', '.js', '.jsx']
},
devServer: {
historyApiFallback: true,
contentBase: './'
}
};