通过webpack意外令牌编译时出现此错误,预期为“,”

Bha*_*shi 0 reactjs redux redux-thunk react-redux redux-devtools-extension

编译此代码时,出现此错误SyntaxError:意外令牌,预期为“,”。我希望你能帮我这个忙。在线错误(13:39)

import { createStore, applyMiddleware } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';
import thunk from 'redux-thunk';
import rootReducers from './reducers';

const initialState = {};

const middleware = [thunk];

const store = createStore({
    rootReducers,
    initialState,
    composeWithDevTools(applyMiddleware(...middleware))
});

export default store;
Run Code Online (Sandbox Code Playgroud)

谢谢

Wil*_*ins 5

您打给您的电话createStore是错误的。它应该是参数列表,而不是对象:

const store = createStore(rootReducers, initialState, composeWithDevTools(applyMiddleware(...middleware)));
Run Code Online (Sandbox Code Playgroud)

正确的功能签名是:

 createStore(reducer, [preloadedState], [enhancer])
Run Code Online (Sandbox Code Playgroud)

这里查看文档