vue3中addRoute路由变化但页面未更新如何解决
作者:小月亮
时间:2025-05-24
来源:正软商城
浏览:3
解决办法,每次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,
});
}
作者最新文章
wps如何生成目录自动生成目录
2026-11-05 11:16
二狗PPT怎么用Word文档生成PPT
2026-11-03 14:55
office打开弹出另存为 修复保存设置
2026-11-03 10:08
火山引擎EMRAI助手导出诊断结果方法
2026-11-01 19:35
navicat连接mysql数据库 配置测试方法
2026-10-26 10:02
热门文章
更多
精品专题
更多
Mac软件
更多
火山引擎 网页版
Windows/ macOS/ Linux
火山引擎是字节跳动旗下企业级云与AI服务平台。聚焦大模型核心能力,依托字节自研豆包多模态大模型,凭借火山方舟一站式平台,提供模型精调、推理部署、智能应用搭建等全链路服务,结合高性能AI算力,助力各行业快速落地大模型数字化与智能化应用。












