Products
GG网络技术分享 2025-11-14 01:48 2
在Vue项目中实现页面刷新鲜的方法有以下几种:
用window.location.reload方法

javascript
methods: {
reloadPage {
window.location.reload;
}
}
用this.$router.go方法
javascript
methods: {
reloadPage {
this.$router.go;
}
}
通过路由跳转到空白页再返回
先说说在路由配置中添加一个空白页的路由, 然后在需要刷新鲜的地方跳转到这玩意儿空白页,再返回到之前页面比方说: javascript router.addRoutes();
methods: { reloadPage { this.$router.push; this.$router.back; } }
用provide/inject实现路由刷新鲜
javascript
// 在顶层组件中
provide {
return {
reload: this.reload
};
},
methods: {
reloadPage {
this.reload;
},
reload {
this.isRouterAlive = false;
this.$nextTick => {
this.isRouterAlive = true;
});
}
}
javascript
inject: ,
methods: {
refresh {
this.reload;
}
}
用Vuereload插件
javascript
const Vuereload = require;
const vuereload = new Vuereload({
port: 8080,
watch:
});
vuereload.connect;
以上方法Neng根据具体需求选择用,以达到页面刷新鲜的效果。
Demand feedback