-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: 查询值为数组时的分隔符问题 #301
Merged
Merged
fix: 查询值为数组时的分隔符问题 #301
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Deploy preview for el-data-table ready! Built with commit ef158b7 |
donaldshen
reviewed
May 11, 2020
donaldshen
reviewed
May 11, 2020
src/utils/query.js
Outdated
) { | ||
return query | ||
.split(delimiter) | ||
.map(param => param.split(equal)) | ||
.reduce((obj, [k, v]) => { | ||
obj[k] = JSON.parse(decodeURIComponent(v)) | ||
// 替换回逗号 | ||
const value = decodeURIComponent(v).split(arrayDelimiter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change
const value = decodeURIComponent(v).split(arrayDelimiter) | |
const value = decodeURIComponent(v).split(arrayDelimiter).join(',') |
Co-authored-by: Donald Shen <donaldshen@users.noreply.github.com>
donaldshen
approved these changes
May 11, 2020
…ble into fix/multi-select-query
eviIIt
approved these changes
May 11, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why
因未知原因(可能是 vue-router?)会将 地址栏 url 自动 decode,此时如果存在数组值,则会在 parse 时先被按
,
分割,导致无法正常解析:How
encode 数组值时,先使用别的分隔符;
同时由于之前发送请求和构造地址栏的 url 用的是同一个方法,但现在由于两者 stringify 的方式不一样,所以增加一个
URLStringify
用于构造发送 axios 请求的参数Test