init
This commit is contained in:
28
utils/tool.js
Normal file
28
utils/tool.js
Normal file
@@ -0,0 +1,28 @@
|
||||
const tool = {}
|
||||
|
||||
/**
|
||||
* localStorage
|
||||
*/
|
||||
tool.data = {
|
||||
set(table, settings) {
|
||||
const _set = JSON.stringify(settings)
|
||||
return wx.setStorageSync(table, _set)
|
||||
},
|
||||
get(table) {
|
||||
let data = wx.getStorageSync(table)
|
||||
try {
|
||||
data = JSON.parse(data)
|
||||
} catch (err) {
|
||||
return null
|
||||
}
|
||||
return data
|
||||
},
|
||||
remove() {
|
||||
return wx.removeStorageSync(table)
|
||||
},
|
||||
clear() {
|
||||
return wx.clearStorageSync()
|
||||
}
|
||||
}
|
||||
|
||||
export default tool
|
||||
Reference in New Issue
Block a user