vue.js - 如何在 vue 路由器中使用冒号 (:)
问题描述
推送后我的网址重新更新我想制作这个网址:
www.abc.com/istanbul-taksim-otelleri?checkin=2019-05-08&checkout=2019-05-16&filters=meal_types:full,half,etc;stars:1,2,4
const query = {
checkin: '2019-05-08',
checkout: '2019-05-16',
filters:'meal_types:full,half,etc;stars:1,2,4'
}
this.router.push({query})
像这样开始之后
www.abc.com/istanbul-taksim-otelleri?checkin=2019-05-08&checkout=2019-05-16&filters=meal_types%3Afull,half,etc%3Bstars%3A1,2,4
你有什么主意吗 ?怎么解决?
解决方案
请参阅https://w3schools.com/tags/ref_urlencode.asp -%3A
只是一个 URL 编码的冒号。URL 编码字符串是标准做法,并且在大多数情况下需要以生成有效的 URL。
如果您需要对 URL 进行解码,decodeURIComponent()
可以使用类似的方法,例如:
const uri = 'www.example.com/:";[]}'
const encodedURI = encodeURIComponent(uri)
console.log(encodedURI)
const decodedURI = decodeURIComponent(encodedURI)
console.log(decodedURI)
推荐阅读
- html - 如何使用 flexbox 列和悬停水平 div?
- regex - Ruby:为正则表达式扫描二进制 IO
- javascript - 如何更改 Vuetify 日历中事件的边框颜色?
- r - 有没有办法在不进入调试模式的情况下将 R 函数中的对象加载到环境中?
- python - 在 Cython 中使用自定义 Python 对象发布 GIL?
- python - 在不知道总页码的情况下通过 url 响应分页,当页面为空时停止
- python - 自定义错误处理程序在 Google Cloud Run 上不起作用
- r - 时间序列数据的子集
- c# - c# 使用距离和角度从起始 3D 点计算 3D 点
- python - 在 Python 中执行延迟执行并获取异常的默认值