The condensed code is as follows :(error in red lines)
The export function permission is yesisAllowedWithThe judgment.
The first time it is loaded, there is no problem. This points to the current instance on which isAllowedWith is mounted.
Here are some scenarios:
For example, when we filter out some data and do some deletion, we want to reset all the parameters and then request new data.
So we have this code:
this.queryData = this.$options.data().queryData
Copy the code
Just execute data() again and get all the initialized data, and you’re done. but
Enclosing isAllowedWith couldn’t find itThis.$options kangkang:
Find isAllowedWith in this.$options.methods.
This.$options.data(), this refers to this.$options, and isAllowedWith is not available.Copy the code
Solution:
- Change this to:
this.queryData = this.$options.data.call(this).queryData
Copy the code
- Not recommended (but can be solved)