useUrlState ​
A hook that store the state into url query.
Install ​
bash
npm i @vue-hooks-plus/use-url-state
Code demonstration ​
API ​
typescript
const state = useUrlState(defaultState, {
localStorageKey: 'localStorageKey',
routerPushFn,
})
interface UseUrlStateOptions {
localStorageKey?: string
}
Params ​
Property | Description | Type | Default |
---|---|---|---|
initialState | default | S | () => S | - |
options | When setting localStorageKey , if url has no parameter, the value of localStorage is used | ||
UseUrlStateOptions | - | routerPushFn |
Result ​
Property | Description | Type |
---|---|---|
state | Url query object | - |