vue3中addRoute路由变化但页面未更新如何解决
作者:小月亮
时间:2024-05-08
来源:互联网
浏览:0
解决办法,每次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,
});
}
作者最新文章
纯纯写作
2026-09-16 17:42
JMeter入门:创建HTTP请求并验证响应结果
2026-09-02 10:20
文件表格制作教程:选择Word或Excel的判断方法
2026-09-02 09:45
多个PPT怎么一次性转PDF?PPT批量转换工具有哪些?
2026-09-02 06:00
PDF图纸转CAD的3种方法及比例校准指南
2026-09-01 18:36
热门文章
更多
精品专题
更多
Mac软件
更多
WINDOWS
更多
Windows 10
Windows
Windows 10 是一款微软推出的经典操作系统,拥有硬件兼容性与多任务处理能力。它更偏向把系统状态查看和常用调节动作放在一起,适合需要持续观察和微调设备状态的场景。
极度公式
Windows/macOS/Linux
极度公式是一款跨平台专业LaTeX公式识别编辑软件,支持OCR公式识别和多平台编辑。和使用说明,避免使用,享受完整功能与稳定支持。做扫描整理、文字提取和表格转换时,它能把识别后的处理步骤接得更顺,资料录入这类场景会省下不少时间。
















