vue3中addRoute路由变化但页面未更新如何解决

广告:宝塔服务器面板,一键全能部署及管理,送你10850元礼包,点我领取~~~

vue3中addRoute路由变化但页面未更新如何解决

解决办法,每次addRoute时 深复制组件对象

import time from "../views/time"function copyObj(obj) {    if (typeof obj == "object") {        if (Array.isArray(obj)) {            let arr = [];            for (let item of obj) {                arr.push(Object.assign(copyObj(item)));            }            return arr;        } else if (obj == null) {            return null;        } else {            let obj1 = {};            for (let index in obj) {                obj1[index] = copyObj((obj[index]));            }            return obj1;        }    } else if (typeof obj == "function") {        return Object.assign(obj);    } else if (typeof obj == undefined) {        return undefined;    } else {        return obj;    }}window.pushTime = function () {    let t = new Date().getTime();    let path = `/time/${t}`;    time = copyObj(time)    this.$router.addRoute({        path,        name: path,        component: time,    });    this.$router.push({        path,    });}
登录后复制

以上就是vue3中addRoute路由变化但页面未更新如何解决的详细内容,更多请关注9543建站博客其它相关文章!

9543建站博客
一个专注于网站开发、微信开发的技术类纯净博客。
作者头像
admin创始人

肥猫,知名SEO博客站长,14年SEO经验。

上一篇:如何在uniapp中实现直接跳转指定页面的功能
下一篇:框架vue是什么

发表评论

关闭广告
关闭广告