Skip to content

Latest commit

 

History

History
45 lines (33 loc) · 868 Bytes

README.md

File metadata and controls

45 lines (33 loc) · 868 Bytes

k-localstorage

enhanced localStorage(加强版 localStorage)

INSTALL

npm i k-localstorage

or

pnpm i k-localstorage

USAGE

For Vue Project in main.js add

import 'k-localstorage'

create a storage.config.js

module.exports = {
	storagePrefix: '',
	localStorageWhiteList: [],
}

storagePrefix: addPrefix (在普通 key 上添加前缀)

localStorageWhiteList: localStorage.clean() will skip array (使用 localStorage.clean()时会跳过里面的值)

then you can use it as native localStorage

localStorage.a = '1'
localStorage.setItem('a', '2')
localStorage.a
localStorage.getItem('a')
localStorage.removeItem('a')
localStorage.clean() // only clean add storagePrefix and skip localStorageWhiteList (只会清除添加了storagePrefix值的前缀,会跳过localStorageWhiteList白名单里的值)