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 收集整理的教程希望能对你有所帮助,如果觉得编程之家不错,可分享给好友!感谢支持

相关文章

可以通过min-width属性来设置el-table-column的最小宽度。以...
yarn dev,当文件变动后,会自动重启。 yanr start不会自动重...
ref 用于创建一个对值的响应式引用。这个值可以是原始值(如...
通过修改 getWK005 函数来实现这一点。这里的 query 参数就是...
<el-form-item label="入库类型" ...
API 变动 样式类名变化: 一些组件的样式类名有所变动,可能需...