File tree Expand file tree Collapse file tree 4 files changed +17
-3
lines changed Expand file tree Collapse file tree 4 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -42979,7 +42979,12 @@ module.exports = {
4297942979 _.runInAsync(options, res)
4298042980 },
4298142981 getStorageSync(key) {
42982- return JSON.parse(localStorage.getItem(key))
42982+ const res = localStorage.getItem(key)
42983+ try {
42984+ return JSON.parse(res)
42985+ } catch (err) {
42986+ return res
42987+ }
4298342988 },
4298442989 getStorageInfo(options) {
4298542990 let res = {errMsg: 'getStorageInfo:ok'}
Original file line number Diff line number Diff line change 11# 更新日志
22
3+ ## 1.5.6
4+
5+ * storage 系列接口支持存取字符串内容
6+
37## 1.5.5
48
59* 修复 global.wx 赋值会覆盖用户模拟的 wx 对象问题
Original file line number Diff line number Diff line change 11{
22 "name" : " miniprogram-simulate" ,
3- "version" : " 1.5.5 " ,
3+ "version" : " 1.5.6 " ,
44 "description" : " tools for miniprogram custom component unit test" ,
55 "main" : " index.js" ,
66 "types" : " index.d.ts" ,
Original file line number Diff line number Diff line change @@ -26,7 +26,12 @@ module.exports = {
2626 _ . runInAsync ( options , res )
2727 } ,
2828 getStorageSync ( key ) {
29- return JSON . parse ( localStorage . getItem ( key ) )
29+ const res = localStorage . getItem ( key )
30+ try {
31+ return JSON . parse ( res )
32+ } catch ( err ) {
33+ return res
34+ }
3035 } ,
3136 getStorageInfo ( options ) {
3237 let res = { errMsg : 'getStorageInfo:ok' }
You can’t perform that action at this time.
0 commit comments