日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學(xué)無先后,達(dá)者為師

網(wǎng)站首頁 編程語言 正文

uniapp封裝本地存儲(chǔ)處理數(shù)據(jù)的方法和具體使用

作者:Wxinin 更新時(shí)間: 2022-04-23 編程語言

js文件

//存儲(chǔ)數(shù)據(jù)
function setStoraged(data1, data2) {
    uni.setStorage({
        key: data1,
        data: JSON.stringify(data2),
    })
}
//獲取數(shù)據(jù)
function getStoraged(data1) {
    const data = uni.getStorageSync(data1);
    if (data) {
        return data;
    } else {
        return [];
    }

}
//刪除數(shù)據(jù)
function removeStoraged(data1) {
    uni.removeStorageSync(data1);
}
export {
    setStoraged,
    getStoraged,
    removeStoraged
}

頁面應(yīng)用

導(dǎo)入

import {
        setStoraged,
        getStoraged,
        removeStoraged
    } from '../../unils/storageData.js'

使用

 setStoraged('value', '123');
  let datas = getStoraged('colData');
  if (datas[0]) {
     datasArr = JSON.parse(getStoraged('colData'));
   }
   removeStoraged('value');         

原文鏈接:https://blog.csdn.net/weixin_44283589/article/details/121771796

欄目分類
最近更新