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工作流
文生图工作流:树枝上站着一只鸟
一只可爱的猫骑着一匹可爱的马ComfyUI工作流
一只乌鸦栖息在一盏神灯上
一个男孩在吃西瓜ComfyUI工作流
冬天的严寒里红梅枝上停留着一只鸟
在森林中心有一座蛇形的房子ComfyUI工作流
池塘边的大熊猫ComfyUI工作流
ai图片扩大comfyui工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!