vue开发中,如何在刷新页面后保证路由不会变化,下面web建站小编给大家简单介绍一下!
具体代码如下:
export default { created() { // 监听beforeunload事件 window.addEventListener("beforeunload", this.saveCurrentPath) }, beforeDestroy() { // 解除beforeunload事件的绑定 window.removeEventListener('beforeunload', this.saveCurrentPath) }, methods: { saveCurrentPath() { //当前路由的路径保存到localStorage localStorage.setItem('currentRoutePath', this.$route.path) } }, mounted() { const currentRoutePath = localStorage.getItem('currentRoutePath') if (currentRoutePath) { this.$router.push(currentRoutePath) //执行后清除localStorage缓存 localStorage.removeItem('currentRoutePath') } } }
Motion for Vue:一个轻量级且功能强大的Vue3动画库
el-table利用:row-style="rowClass"设置指定行变色
一款免费开源效果酷炫的 Vue / React 大屏数据展示组件库——DataV
上面是“vue在刷新页面后如何保证路由不变”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_4730.html
workflows工作流
一棵树从鸟笼里长出来的梦幻般场景
一幅3D农场游戏画面ComfyUI工作流
树枝上一只色彩斑斓的小鸟
一个穿过泥泞雷区的士兵ComfyUI工作流
一架受损严重的宇宙飞船内有一只猫
沙漠里一只红黑相间的蝎子
在月球上穿着太空服的宇航员
图生图局部重绘ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!