在redux中的spread运算符处显示错误

在redux中的spread运算符处显示错误,redux,Redux,const newState={…state}; ^^^SyntaxError:意外标记 当我尝试一个简单的redux程序来增加年龄时,我得到了上面的错误。 代码如下: const {createStore} = require('redux'); const initialState ={ age : 21 } const myReducer = (state = initialState, action) =>{ const newState = {...state};

const newState={…state}; ^^^SyntaxError:意外标记

当我尝试一个简单的redux程序来增加年龄时,我得到了上面的错误。 代码如下:

const {createStore} = require('redux');
const initialState ={
    age : 21
}
const myReducer = (state = initialState, action) =>{
    const newState = {...state};
    if(action.type === 'ADD')
        newState.age +=1;
    return newState;
}
const store = createStore(myReducer);
store.dispatch({type : 'ADD'})
console.log(store.getState());

你用的是什么浏览器?听起来它不支持ES6 spread语法。请参阅MDN中的表。您不能在IE、Edge或Safari中使用它。我使用的是IE。这就是问题所在。