>[success] # Storage存儲
1. 小程序提供了專門的Storage用于[進行本地存儲](https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.setStorageSync.html),不需要像其他瀏覽器要轉換,已經幫助取出時候就是轉換好的類型
>[danger] ##### 同步存取的方法
1. wx.setStorageSync(string key, any data)
2. wx.getStorageSync(string key)
3. wx.removeStorageSync(string key)
4. wx.clearStorageSync()
>[danger] ##### 異步存儲數據的方法
1. wx.setStorage(Object object)
2. wx.getStorage(Object object)
3. wx.removeStorage(Object object)
4. wx.clearStorage(Object object)
>[danger] ##### 案例
~~~
onLocalStorage() {
// 1.存儲一些鍵值對
wx.setStorageSync('name', 'aaa')
wx.setStorageSync('age', 18)
wx.setStorageSync('friends', ['abc', 'cba', 'nba'])
// 2.獲取storage中內容
const name = wx.getStorageSync('name')
const age = wx.getStorageSync('age')
const friends = wx.getStorageSync('friends')
console.log(name, age, friends)
// 3.刪除storage中內容
wx.removeStorageSync('name')
// 4.清空storage中內容
wx.clearStorageSync()
// 異步操作
wx.setStorage({
key: 'books',
data: '哈哈哈',
encrypt: true, // 開啟加密
success: (res) => {
wx.getStorage({
key: 'books',
encrypt: true,
success: (res) => {
console.log(res)
},
})
},
})
console.log('-------')
},
~~~
- 小程序了解
- webview 是什么
- Native App、Web App、Hybrid App
- 小程序架構模型
- 小程序配置文件
- app.js -- App函數
- 頁面.js -- page
- 生命周期????
- 小程序 -- 頁面wxml
- 小程序 -- WXS
- 小程序 -- 事件
- 小程序 -- 樣式wxss
- 小程序 -- 組件開發
- 小程序 -- 組件插槽
- 小程序 -- 組件的生命周期
- 組件總結
- 小程序 -- 混入
- 小程序基本組件
- text -- 文本
- view -- 視圖容器
- button -- 按鈕
- image -- 圖片
- scroll-view -- 滾動容器
- input -- 雙向綁定
- 通用屬性
- 小程序常用Api
- 微信網絡請求
- 微信小程序彈窗
- 微信小程序分享
- 獲取設備信息 / 獲取位置信息
- Storage存儲
- 頁面跳轉
- 小程序登錄