New to Vue, trying to figure out something. I'm using this "Data":
data() {
return {
currentPage: 0,
nextPage: '',
previousPage: '',
left: '',
opacity: '',
scale: '',
}
},
Trying to use the data variables inside a method looks like this:
methods: {
isStageOneDone: function () {
var animating;
if(animating) return false;
animating = true;
this.currentPage;
console.log("CurrentPage =>", currentPage);
}
}
But I keep getting this error:
Uncaught ReferenceError: currentPage is not defined
What am I missing? I looked into the Vue docs and it seems ok I think
Edit: Is it possible that because of the return() the error occurs?
return {
will be interpreted asreturn {;
due to what's known as Automatic Semicolon Insertion. For more info, see stackoverflow.com/questions/8528557/…) – EdriccurrentPage
) which has not yet been defined in the scope of your function (becausethis.currentPage
is notcurrentPage
). However, even if you did define it prior to using it, you'd only remove the error, it wouldn't do anything. So, what are you trying to do with that code? – tao