1.创建storage.js

// 封装localStorsge本地储存方法
var storage = {
    set(key, value) {
        localStorage.setItem(key, JSON.stringify(value));
    },
    get(key) {
      return JSON.parse(localStorage.getItem(key));
    },
    remove(key) {
        localStorage.removeItem(key)
    }
}
export default storage

2 . 引用

import Storage from '@/model/storage.js'
Logo

前往低代码交流专区

更多推荐