当我在 IE11 或更低版本中尝试我的 vue.js 应用程序时,我得到 Error SCRIPT1003 excepted : in the console which points to routeContent。我的 Snytax 看起来像这样:
var store = new Vuex.Store({
state: {
routeContent: null
},
mutations: {
routeContent(state, payload) {
state.routeContent = payload
document.title = payload.title
}
}
})
最佳答案
您正在尝试使用 object method shorthand在您定义的 routeContent
- this isn't supported in Internet Explorer or Safari .
您有两个选择,要么开始使用转译器,例如 Babel将现代 JS 语法转换为旧浏览器可以理解的形式 - 或者,如果这太麻烦,您可以切换回使用良好的老式函数语法:
var store = new Vuex.Store({
state: {
routeContent: null
},
mutations: {
routeContent: function (state, payload) {
state.routeContent = payload
document.title = payload.title
}
}
})
关于javascript - Vue.js 语法错误 (SCRIPT1003) IE11 及更低版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40281270/