欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

如何在微信小程序中存setStorage

 更新時(shí)間:2019年12月13日 11:29:12   作者:圣誕。  
這篇文章主要介紹了如何在微信小程序中存setStorage,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

這篇文章主要介紹了如何在微信小程序中存setStorage,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

在js中存入setStorage,key是你的鍵,data是你的值

  wx.setStorage({
   key: 'mm',
   data: 1,
  })
  // 獲取getStorageSync的方式
 
  console.log(wx.getStorageSync('mm')) #獲取的方式

接下來是或數(shù)據(jù)中的存取 ,其實(shí)是一樣的啦,直接上代碼

js文件中代碼

 onLoad: function (options) {
  var thit = this
  wx.request({ //請求地址
   url: 'http://127.0.0.1:8000/api/index/',
   method: 'get',
   // data:{},//沒有數(shù)據(jù)可以不寫 
   header: { //請求頭
    'content-type': 'application/json'
    // "Content-Type": "application/x-www-form-urlencoded"
   },
   //如果在sucess直接寫this就變成了wx.request()的this了
   success: function (res) {
    // res.data相當(dāng)于ajax里面的data,為后臺返回的數(shù)據(jù)
    //打印后臺返回的數(shù)據(jù)
    console.log(res.data.message)
    //直接把后臺返回的數(shù)據(jù) 賦值給names 就可以直接調(diào)用names了
    thit.setData({
     names: res.data.message,
     names1: res.data.message1, //返回的第二條數(shù)據(jù)
     names2: res.data.message2 // 第三條數(shù)據(jù)
    })

  // 存入setStorage
    wx.setStorage({
     key: 'kkk',
     data: res.data.message2,  //存第三條數(shù)據(jù)
    })
    //查看方式 定義一個(gè)變量
      var eee = wx.getStorageSync('kkk')
    console.log(eee)
   }
  })
   },

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論