A ref that stores / retrieves from localStorage.
npm install vue-localstorage-ref
or
yarn add vue-localstorage-ref
import useLocalStorageRef from "vue-localstorage-ref";
// ...
setup() {
const stretchWidth = useLocalStorageRef("stretchWidth", 5);
return {stretchWidth}
}
-
key
:string
The key to save the ref to in
localStorage
. -
initialValue
:any
The value the ref should be if no value exists in
localStorage
. -
Returns:
Ref
A ref that will have an initial value from
localStorage
, and will save changes tolocalStorage
on change.
MIT