const STORAGE_KEY = 'aqd'
export default {
getStorage() {
return JSON.parse(window.localStorage.getItem(STORAGE_KEY) || '{}')
},
clearModuleKye(key:string,module_name:string) {
const val = this.getStorage()
if (!val[module_name]) return
delete val[module_name][key]
return window.localStorage.setItem(STORAGE_KEY,JSON.stringify(val))
},
clearKey(key:string) {
const val = this.getStorage()
delete val[key]
return window.localStorage.setItem(STORAGE_KEY,JSON.stringify(val))
},
getItemModule(key:string,module_name:string) {
const val = this.getItemKey(module_name)
if (val) return val[key]
return this.getStorage()[key]
},
getItemKey(key:string) {
return this.getStorage()[key]
},
setItemMOduleKey(key:string,value:any,module_name:string) {
const val = this.getStorage()
val[key] = value
this.setItemKey(module_name,val)
},
setItemKey(key:string,value:any) {
const val = this.getStorage()
val[key] = value
window.localStorage.setItem(STORAGE_KEY,JSON.stringify(val))
}
}
测试没有问题放心使用
npm i vue3-lazyload
import VueLazyLoad from 'vue3-lazyload'
app.use(VueLazyLoad,{
loading: require('@/assets/images/loading.gif')
})
调用
<img v-lazy="item.imgsmall" alt="">
这个是支持ts的,要加require