npm i vue-ls
新建 storage.ts
import Storage from 'vue-ls';
const options = {
namespace: 'vuejs__', // key prefix
name: 'ls', // name variable Vue.[ls] or this.[$ls],
storage: 'local', // storage name session, local, memory
};
const { ls } = Storage.useStorage(options)
export default ls
组件导入
<script lang="ts" setup>
import ls from "@/util/storage/"
ls.set('user','admin',60*60*1000)
</script>
标签:typescript,name,storage,Storage,60,vue,ls
From: https://www.cnblogs.com/mistrainy/p/17137030.html