there is a method in a component:
name: "user",
data() {
const checkExist = (rule, value, callback) => {
if (value) {
this.$http.get(....).then(res => {
if (res.id === this.itemId) {
...
}
});
}
callback();
};
return {
itemId: "",
rules: {
name: [{ validator: checkExist, message: "" }];
},
};
},
how this checkExist is extracted as a public function can be directly applied in other components. One thing that is particularly unclear is how to deal with it scientifically after using axios"s wrapper this.$http, extraction as a common function in the function. And what about references to this.itemId?