-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
fix(useRouteParams): solve the problem of the default value remaining in the URL #4737
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
base: main
Are you sure you want to change the base?
Conversation
…t "invisible and add id to the function config
…t "invisible and add id to the function config
packages/core/useFileDialog/index.ts
Outdated
/** | ||
* Set the id attribute for the input element (for accessibility and testing purposes). | ||
*/ | ||
id?: string | ||
} |
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.
we should wait for this: #4679
playgrounds/vite/src/App.vue
Outdated
// const userName=useRouteQuery('userName','Mike') | ||
// userName.value='Mike' | ||
const userId=useRouteParams('userId',123) | ||
userId.value=1 | ||
userId.value=999 | ||
const route=useRoute() | ||
const handleClick=()=>{ | ||
console.log(userId.value); | ||
console.log(route.fullPath); | ||
console.log(route.path); | ||
console.log(route.params); | ||
|
||
// console.log(userName.value); | ||
// console.log(route.fullPath); | ||
// console.log(route.path); | ||
// console.log(route.params); | ||
// console.log(route.query); | ||
} |
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.
please remove the playground changes 😅
../../README.md |
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.
👀
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.
this causes linting to crash
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.
Sorry, there might be some issues with the version of the code I submitted. I will adjust it immediately.
Before submitting the PR, please make sure you do the following
fixes #123
).Description
This PR fixes #4732
The problem that occurred:
There is a default value, but it is not retained in the URL.
The judgment on whether to use the default value can only be made when assigning a value to the ref reference, which triggers the set function (and the judgment logic is incorrect).
solution:
Perform logical judgment outside the scope of the
set
function. If there is a default value, add it to theparam
and_paramsQueue
.Inside the scope of the
set
function, if a manual assignment is made, replace the default value.Move the code logic for updating the current
params
parameter, which is currently placed in thenextTick
function, outside theset
function. This way, it can break free from the constraint that theparams
of the current route can only be updated when a value is assigned to theref
reference.test:
It has been thoroughly tested. When there is a default value and no manual assignment is made, the default value can be added to the
params
parameter in theroute
.Additional context
Please review whether my Pull Request (PR) is correct. If it is correct, I will continue to expand it to
useRouteQuery
.