含date的对象,setStorage/getStorage后字段就少了8小时
onClick_test() { var dateField = new Date(); var params = { dateField: dateField, dateField_ms: dateField.getTime() }; console.log( '原始数据' ); console.log(params); console.log(dateField); wx.setStorageSync( 'params' , params); wx.setStorageSync( 'dateField' , dateField); var params2 = wx.getStorageSync( 'params' ); var dateField2 = wx.getStorageSync( 'dateField' ); console.log( '序列化之后再取出的数据' ); console.log(params2); console.log(dateField2); }, |
在模拟器上的运行结果
原始数据
10:11:31.593 index.js? [sm]:24 {dateField: Sat Jul 28 2018 10:11:31 GMT+0800 (CST), dateField_ms: 1532743891590}
10:11:31.597 index.js? [sm]:25 Sat Jul 28 2018 10:11:31 GMT+0800 (CST)
10:11:31.656 index.js? [sm]:30 序列化之后再取出的数据
10:11:31.657 index.js? [sm]:31 {dateField: “2018-07-28T02:11:31.590Z”, dateField_ms: 1532743891590}
10:11:31.657 index.js? [sm]:32 Sat Jul 28 2018 10:11:31 GMT+0800 (CST)
重点是
1 含有date型字段的对象序列化/反序列化后为变
2 单独的date类型序列化/反序列化后正常
调试基础库 2.2.1