用wx.setStorage、wx.getStorageとwx.getStorageSyncページ間転送


用wx.setStorage、wx.getStorageとwx.getStorageSyncページ間転送


まずwxを格納.setStorage
Page({
data: {
testnum:""// 

},
test:function(){
var Num = this.data.testnum;

wx.setStorage({// 

  key:"testNum",

  data:Num

})

}
})別のページでtestnumを取得する方法1 wx.getStorage
Page({
data: {
testnum:""// 

},
onLoad:function(option){
var that = this,

wx.getStorage({// 

  key:"testNum",

  success:function(res){

    that.setData({

      testnum:res.data

    )};

  },

})

}
}) ②wx.getStorageSync
Page({
data: {
testnum:""// 

},
onLoad:function(option){
var num = wx.getStorageSync('testNum');//wx.getStorageSync(key), 

this.setData({

  testnum:testnum

});

}
})