vue.js - Vue Router - 更新或清除查询
问题描述
我正在编写一个 ui 过滤器,它应该将所有活动过滤器作为查询参数输出
const query = this.$route.query
if (!query[type]) {
return this.$router.push({ query: { ...query, [type]: value } }) // works fine!
}
if (Array.isArray(query[type])) {
// some changes
}
this.$router.replace({ query: { ...query } })
但它不起作用!如果之前的参数是一个字符串,然后变异成一个数组(例如:query: '1'
toquery: [1, 2]
那么路由器会忽略更新。或者如果所有过滤器都已清除,我需要清除地址栏。
解决方案
推荐阅读
- node.js - 使用 Cloud Firestore 更新触发器删除 Firestore 中的文档
- ios - 如何在 xamarin iOS 中为 UIImageView 设置静态高度和宽度
- javascript - 在没有更改后,在 Next.js 应用程序中读取 Firestore 的突然飙升 - 请参见图表
- javascript - 未分配 JavaScript 变量 - 提款错误修复时的 Paypal 空白屏幕
- html - 图像周围有不需要的填充/空间
- shell - 如何使用 shell 脚本查找特定文件类型的文件
- android - 同一行中的两个线性布局。第一个必须填满所有剩余空间
- c# - Embed PowerBI with authentication error (AADSTS50076)
- javascript - 查找对象值数组的总组合
- karate - 如何在空手道 dsl 中以 yyyy-mm-dd 格式提取当前日期、月份和年份?