1.场景
在处理列表时,常常有删除一条数据或者新增数据之后需要重新刷新当前页面的需求。
2.遇到的问题
1. 用vue-router重新路由到当前页面,页面是不进行刷新的
2.采用window.reload(),
或者router.go(0)
刷新时,整个浏览器进行了重新加载,闪烁,体验不好
3.解决方法
provide / inject 组合
作用:允许一个祖先组件向其所有子孙后代注入一个依赖,不论组件层次有多深,并在起上下游关系成立的时间里始终生效。
我的项目配置:
①home.vue
rush:js;">
dalive">
imsun; white-space: normal; word-spacing: 0px; text-transform: none; float: none; font-weight: normal; color: rgb(0,0); font-style: normal; orphans: 2; widows: 2; display: inline !important; letter-spacing: normal; text-indent: 0px; font-variant-ligatures: normal; font-variant-caps: normal; -webkit-text-stroke-width: 0px">
rush:js;">
export default {
provide() {
return {
reload: this.reload
}
},data(){
isReloadalive : true
},methods: {
reload() {
this.isReloadalive = false;
this.$nextTick(function(){
this.isReloadalive = true;
})
}
}
}
内容管理 - 投顾推荐 tgtj.vue
{
this.$message({ message: data.ret.retMsg });
if(data.ret.succeed){
this.reload() // 调用刷新方法
}
});
}
}
}
总结
以上所述是小编给大家介绍的vue this.reload 方法 配置。编程之家 jb51.cc 收集整理的教程希望能对你有所帮助,如果觉得编程之家不错,可分享给好友!感谢支持。