Micro letter how small program stored setStorage

Deposit setStorage in the js, key is your key, data is your value

    wx.setStorage({
      key: 'mm',
      data: 1,
    })
    // Get getStorageSync way
 
    console.log (wx.getStorageSync ( 'mm')) # acquired manner
 
 
 
Next is a data access or, in fact, it is the same, the code directly on
Js code file.
 
  onLoad: function (options) {
    var thit = this
    wx.request ({// request address
      url: 'http://127.0.0.1:8000/api/index/',
      method: 'get',
      // data: {}, // no data can not write 
      header: {// request header
        'content-type': 'application/json'
        // "Content-Type": "application/x-www-form-urlencoded"
      },
      // If write directly in this sucess became wx.request () is this the
      success: function (res) {
        // res.data equivalent ajax inside data, return data for the background
        // print the data returned by the background
        console.log(res.data.message)
        // assign data directly to return back to the names you can call names directly
        thit.setData({
          names: res.data.message,
          names1: res.data.message1, // return the second data
          names2: res.data.message2 // Article data
        })

    // deposit setStorage
        wx.setStorage({
          key: 'kkk',
          data: res.data.message2, // third data storage
        })
        // define a variable view
           var eee = wx.getStorageSync('kkk')
        console.log(eee)
      }
    })
      },

Guess you like

Origin www.cnblogs.com/pp8080/p/12019757.html