typescript+vue3使用vue-ls

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>
posted @ 2023-02-20 13:16  越甲鸣吾君  阅读(741)  评论(0编辑  收藏  举报