baidu / amis

前端低代码框架,通过 JSON 配置就能生成各种页面。
https://baidu.github.io/amis/
Apache License 2.0
17.18k stars 2.49k forks source link

怎么可以实现link跳转页面的时候携带参数重新渲染 #10430

Open wiktsweet opened 3 months ago

wiktsweet commented 3 months ago

实现场景:

怎么可以实现link跳转页面的时候携带参数重新渲染

存在的问题:

image

当前方案:

这是我自定义js `// 重新加载页面的函数 function reloadPageWithParams() { // 获取地址栏参数 const urlParams = getUrlParams();

// 构建新的 URL let newUrl = window.location.origin + window.location.pathname; let isFirstParam = true; for (const [key, value] of Object.entries(urlParams)) { if (key !== 'timestamp') { // 如果参数中不包含时间戳参数,则添加时间戳参数 if (isFirstParam) { newUrl += ?${key}=${value}; isFirstParam = false; } else { newUrl += &${key}=${value}; } } } // 添加时间戳参数,确保每次请求都是唯一的 newUrl += &timestamp=${Date.now()};

// 通过在不刷新整个页面的情况下重新加载页面的方式,使用 fetch API fetch(newUrl, { method: 'GET', cache: 'no- cache' }) .then(response => { if (response.ok) { console.log("页面重新加载成功"); } else { console.error("页面重新加载失败"); } }) .catch(error => { console.error("页面重新加载出错:", error); }); } reloadPageWithParams(); `

lhtuling commented 1 month ago

用事件动作应该可以实现,给所有关联的组件主动赋值修改就可以了,研究看看! https://aisuda.bce.baidu.com/amis/zh-CN/docs/concepts/event-action#%E6%9B%B4%E6%96%B0%E7%BB%84%E4%BB%B6%E6%95%B0%E6%8D%AE

Amis低代码前端框架交流群【QQ1群】:717791727 Amis低代码前端框架交流群【QQ2群】:721182449