怎么在全局函数中使用this
粉丝福利 : 关注VUE中文社区公众号,回复视频领取粉丝福利
我创建了一个全局的函数文件,
export default {
install: function (Vue) {
Vue.prototype.pageSize = 10;
Vue.prototype.total = 0;
Vue.prototype.page = 1;
Vue.prototype.filterData = {};
Vue.prototype.model = [];
Vue.prototype.searchSubmit = function (e) {
this.filterData = e;
for (let k in e) {
if (k != "newOrderBy" && k != "isAsc" && k != "orderBy") {
this.$set(this.filterData, k, e[k]);
}
}
this.page = 1;
this.loadData();
};
当我在vue组件上调用的时候
<Search :filters=“filterData”
[@searchSubmit](/user/searchSubmit)=“searchSubmit”>
this = null。问题是 我怎么取得当前的vue对象