微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

vue this.reload 方法 配置

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; }) } } }

②使用reload方法页面

内容管理 - 投顾推荐 tgtj.vue

{ this.$message({ message: data.ret.retMsg }); if(data.ret.succeed){ this.reload() // 调用刷新方法 } }); } } }

总结

以上所述是小编给大家介绍的vue this.reload 方法 配置。编程之家 jb51.cc 收集整理的教程希望能对你有所帮助,如果觉得编程之家不错,可分享给好友!感谢支持

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐