Reputation: 93
When i try my vue.js app in IE11 or lower i get Error SCRIPT1003 excepted : in the console which points to routeContent. My Snytax looks like this:
var store = new Vuex.Store({
state: {
routeContent: null
},
mutations: {
routeContent(state, payload) {
state.routeContent = payload
document.title = payload.title
}
}
})
Upvotes: 1
Views: 6648
Reputation: 35797
You're trying to use the object method shorthand in your definition of routeContent
- this isn't supported in Internet Explorer or Safari.
The two options you have are to either start using a transpiler such as Babel to convert modern JS syntax into a form that older browsers can understand - or, if that's too much hassle, you could just switch back to using the good old-fashioned function syntax:
var store = new Vuex.Store({
state: {
routeContent: null
},
mutations: {
routeContent: function (state, payload) {
state.routeContent = payload
document.title = payload.title
}
}
})
Upvotes: 3
Reputation: 24265
Here is another similar question: javascript Ajax SCRIPT1003: Expected ':' in IE 11
I think you may have to do as follows:
mutations: {
routeContent: function(state, payload) { // making it obvious that this is a function
state.routeContent = payload;
document.title = payload.title; // and also the semicolons
}
}
Upvotes: 1