利用Vue里面的
provide+inject
组合
1.首先需要修改view/index主页面
provide(){
return{
reload: this.reload
};
},
methods: {
reload(flag){
if(flag){
this.$nextTick(function(){
this.$refs['app'].getList1(1,30);
this.$refs['app'].contentList = [];
})
}else{
setTimeout(()=>{
this.$refs['app'].getList2(1,30);
this.$refs['app'].contentList = [];
},500)
}
}
}
2. 到需要刷新的页面进行引用,使用inject导入引用reload,然后直接调用即可。
inject: ["reload"], //注入 - 和methods同级
methods: {
switchTab() {
this.reload(1); //局部刷新
}
}