微信小程式開發(一) 資料儲存

2021-08-05 21:13:04 字數 996 閱讀 3704

二. 同步儲存

(1)wx.setstoragesync(key,data)

將 data 儲存在本地快取中指定的 key 中,會覆蓋掉原來該 key 對應的內容,這是乙個同步介面。
wx.setstoragesync('key', 'value')
(2)wx.getstoragesync(key)

從本地快取中同步獲取指定 key 對應的內容。
wx.getstoragesync('key')
三. 資料刪除

(1)wx.removestorage(object)

從本地快取中非同步移除指定 key 。
wx.removestorage(,

fail: function

(res) ,

complete: function

(res)

})

(2)wx.removestoragesync(key)

從本地快取中同步移除指定 key 。
wx.removestoragesync('key')
(3)wx.clearstorage()

清理本地資料快取。
wx.clearstorage()
(4)wx.clearstoragesync()

同步清理本地資料快取
wx.clearstoragesync()

微信小程式(一) 資料繫結

功能 我做的頁面是顯示上課班列表,所以後台返回乙個teachclasslist 最終效果如下圖所示 wxml頁面 class touch item data index style display flex bindtouchstart touchstart bindtouchmove touchm...

微信小程式如何儲存資料?

wx.setstoragesync list ll 語法 wx.setstoragesync 儲存的名 儲存的值 讀取 wx.getstoragesync list 語法 wx.getstoragesync 儲存的名 如果儲存在本地,想一重新整理頁面的時候我們直接獲取到資料可以這樣寫一下 生命週期函...

微信小程式開發

一 開發準備 二 開發工具的使用 編碼目錄結構 1 wxml的功能 資料繫結 資料繫結使用 mustache 語法 雙大括號 將變數包起來。列表渲染 wx for 在元件上使用 wx for 控制屬性繫結乙個陣列,即可使用陣列中各項的資料重複渲染該元件。block wx for 類似 block w...