Skip to content
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: 查询值为数组时的持久化问题 #300

Merged
merged 1 commit into from
May 8, 2020

Conversation

gd4Ark
Copy link
Contributor

@gd4Ark gd4Ark commented May 8, 2020

Why

当查询值为数组时,经过 queryUtil 后会将整个数组变成字符串,例如:

const value = [1,2,3,4]

const queryValue = value.toString().trim() // 1,2,3,4

const stringifyValue = encodeURIComponent(queryValue) // 1%2C2%2C3%2C4

const parseValue = decodeURIComponent(stringifyValue) // 1,2,3,4

How

在 encode 前先把值进行 JSON.stringify(),在 decode 后进行 JSON.parse(),同时把 JSON.stringify 放到 queryUtil 内部处理,则外部不再需要进行额外处理

const value = [1,2,3,4]

const stringifyValue = encodeURIComponent(JSON.stringify(queryValue)) // %5B1%2C2%2C3%2C4%5D

const parseValue = JSON.parse(decodeURIComponent(stringifyValue)) //  [1, 2, 3, 4]

Test

before

2020-05-08 14 21 07

after

2020-05-08 14 18 09

Docs

  • 在 basic.md 添加可多选的示例

@auto-add-label auto-add-label bot added the bug Something isn't working label May 8, 2020
@netlify
Copy link

netlify bot commented May 8, 2020

Deploy preview for el-data-table ready!

Built with commit 9da83cf

https://deploy-preview-300--el-data-table.netlify.app

@donaldshen donaldshen merged commit 0158c32 into FEMessage:dev May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants