1.简单方法

//第一种:使用location对象的reload()方法
window.location.reload();
//第二种:使用编程式导航
this.$router.go(0);

2.使用vue中provide和inject(推荐)

在app.vue:
<template> <div id="app"> <router-view v-if="showRouter"></router-view> </div>
</template> <script> export default { name: 'App', provide (){ return { reload:
this.reload } }, data (){ return { showRouter: true } }, methods: { reload (){
this.showRouter = false this.$nextTick(()=>{ this.showRouter = true }) } } }
</script> <style scoped> </style>
在需要刷新的vue组件:
<template> <button @click="refreshbtn">刷新</button> </template> <script> export
default { inject: ['reload'], methods: { refreshbtn() { this.reload() } } };
</script> <style scoped> </style>

技术
下载桌面版
GitHub
百度网盘(提取码:draw)
Gitee
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:766591547
关注微信