vue3中addRoute路由变化但页面未更新如何解决
作者:小月亮
时间:2025-05-24
浏览:1
解决办法,每次addRoute时深复制组件对象importtimefrom"../views/time"functioncopyObj(obj){if(typeofobj=="object"){if(Array.isArray(obj)){letarr=[];for(letitemofobj){arr.push(Object.assign(copyObj(item)));}returnarr;}elseif(obj==null){returnnull;}else{letobj1={};for(letind
本文目录
解决办法,每次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,
});
}
作者最新文章
火山引擎EMRAI助手导出诊断结果方法
2026-11-01 19:35
navicat连接mysql数据库 配置测试方法
2026-10-26 10:02
用音述AI分轨功能做采样(Sampling):打造你的Hip-Hop采样库
2026-10-14 23:46
漫蛙漫画app下载入口
2026-10-13 13:18
漫蛙漫画免费下载最新版本
2026-10-13 13:18
热门文章
更多
精品专题
更多
Mac软件
更多
WINDOWS
更多





























