Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
take_order
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
和慭琛
take_order
Commits
e30880d1
Commit
e30880d1
authored
May 11, 2021
by
Damon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
封装缓存类
parent
86073322
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
cache.js
take-order/common/cache.js
+55
-0
No files found.
take-order/common/cache.js
0 → 100644
View file @
e30880d1
class
cache
{
//存储在本地缓存指定的name中
setCache
(
name
,
data
)
{
try
{
uni
.
setStorageSync
(
name
,
data
);
}
catch
(
e
)
{
console
.
log
(
e
)
}
}
//从本地缓存中读取置顶name对应的内容
getCache
(
name
)
{
let
data
;
try
{
data
=
uni
.
getStorageSync
(
name
);
}
catch
(
e
)
{
console
.
log
(
e
);
}
return
data
;
}
//从本地缓存中移出指定key
removeCache
(
name
)
{
try
{
uni
.
removeStorageSync
(
name
);
}
catch
(
e
)
{
//TODO handle the exception
console
.
log
(
e
);
}
}
//返回一个布尔值,表示name是否在本地缓存之中
checkCache
(
name
)
{
let
value
;
try
{
const
res
=
uni
.
getStorageInfoSync
()
value
=
res
.
keys
.
includes
(
name
)
}
catch
(
e
)
{
console
.
log
(
e
)
}
return
value
}
//清除本地数据缓存
clearCache
(){
try
{
uni
.
clearStorageSync
();
}
catch
(
e
){
console
.
log
(
e
)
}
}
}
let
cacheFunc
=
new
cache
();
export
default
cacheFunc
;
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment