5👍
This:
data: () => ({
...
})
Should be this:
data () {
...
}
If you use an arrow function you’ll end up with the this
reference pointing at the wrong object.
There is a note about this in the docs: https://v2.vuejs.org/v2/api/#data
Note that if you use an arrow function with the data property,
this
won’t be the component’s instance…
- [Vuejs]-Jest or Mocha with Vue: SyntaxError: Cannot use import statement outside a module
- [Vuejs]-VueJS 2 – Update modal component when passing in data
0👍
Here is the corrected code. You have to use a function with return.
props: {
propsTitle: String,
propsLevel: Number,
propsProgress: Number,
},
data() {
console.log(this)
return {
title: this.propsTitle,
progress: this.propsProgress,
level: this.propsLevel,
activeBtnTxt: "Start",
isStarted: false
}
},
Source:stackexchange.com