中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

濟南網絡廣播電視臺北京關鍵詞優(yōu)化報價

濟南網絡廣播電視臺,北京關鍵詞優(yōu)化報價,泉州網站制作案例,湖南疫情最新情況新增2例在哪里一、什么是 localForage 當我們的存儲量比較大的時候,我們一定會想到我們的 indexedDB,讓我們在瀏覽器中也可以 使用數(shù)據(jù)庫這種形式來玩轉本地化存儲,然而 indexedDB 的使用是比較繁瑣而復雜的, 有一定的學習成本,但 …

一、什么是 localForage

當我們的存儲量比較大的時候,我們一定會想到我們的 indexedDB,讓我們在瀏覽器中也可以
使用數(shù)據(jù)庫這種形式來玩轉本地化存儲,然而 indexedDB 的使用是比較繁瑣而復雜的,
有一定的學習成本,但 localForage 的出現(xiàn)幾乎抹平了這個缺陷,讓我們輕松無負擔的在
瀏覽器中使用 indexedDB。localStorage如果存儲內容多的話會消耗內存空間,會導致頁面變卡。
那么 IndexedDB 存儲量過多的話會導致頁面變卡嗎?不會有太大影響,因為 IndexedDB 的讀取和存儲都是異步的,不會阻塞瀏覽器進程。IndexedDB 的儲存空間比LocalStorage 大得多,一般可達到500M,甚至沒有上限。而localForage 是基于 indexedDB 封裝的庫,通過它我們可以簡化 IndexedDB 的使用。

若瀏覽器不支持 IndexedDB 或 WebSQL,則使用 localStorage。在所有主流瀏覽器中都可用:Chrome,Firefox,IE 和 Safari(包括 Safari Mobile)。

二、localForage 的使用

1,安裝和引入

npm install localforage
import localforage from 'localforage'

2、創(chuàng)建一個 indexedDB

const myIndexedDB = localforage.createInstance({name: 'myIndexedDB',
})

3、存儲

myIndexedDB.setItem(key, value)

4、取值(由于indexedDB的存取都是異步的,建議使用 promise.then() 或 async/await 去讀值)

myIndexedDB.getItem('somekey').then(function (value) {// we got our value
}).catch(function (err) {// we got an error
});

或者

try {const value = await myIndexedDB.getItem('somekey');// This code runs once the value has been loaded// from the offline store.console.log(value);
} catch (err) {// This code runs if there were any errors.console.log(err);
}

?5、刪除

myIndexedDB.removeItem('somekey')

6、重置數(shù)據(jù)庫

myIndexedDB.clear()


VUE3 推薦使用 Pinia 管理 localForage

// store/indexedDB.ts
import { defineStore } from 'pinia'
import localforage from 'localforage'export const useIndexedDBStore = defineStore('indexedDB', {state: () => ({filesDB: localforage.createInstance({name: 'filesDB',}),usersDB: localforage.createInstance({name: 'usersDB',}),responseDB: localforage.createInstance({name: 'responseDB',}),}),actions: {async setfilesDB(key: string, value: any) {this.filesDB.setItem(key, value)},}
})

?我們使用的時候,就直接調用 store 中的方法

import { useIndexedDBStore } from '@/store/indexedDB'
const indexedDBStore = useIndexedDBStore()
const file1 = {a: 'hello'}
indexedDBStore.setfilesDB('file1', file1)

?《完》

http://www.risenshineclean.com/news/46691.html

相關文章:

  • 域名服務器的四種類型營口seo
  • 網站建設需要哪些方面愛站網權重查詢
  • 深圳燃氣公司地址在哪里哈爾濱seo關鍵字優(yōu)化
  • 網站首頁大圖怎么做優(yōu)化推廣網站排名
  • 知名網站建設定制如何聯(lián)系百度客服
  • 電梯配件做外貿在哪個網站上海網絡推廣招聘
  • 網站開發(fā)調研方案中小企業(yè)網絡營銷現(xiàn)狀
  • 如何做網站首頁百度查重
  • 網站代碼制作軟件網絡營銷五種方法
  • wordpress國外主題慢點擊排名優(yōu)化
  • 網站后臺動態(tài)播放怎么做的招代理最好的推廣方式
  • 網站如何兼容大多瀏覽器怎么注冊電商平臺
  • 溧陽網站設計唐山seo排名
  • 做安全題目是哪個網站長沙百度網站快速排名
  • 蘇州網站建設設計公司免費網站建設制作
  • 做內貿只要有什么網絡推廣網站搜索引擎技術基礎
  • 網站功能測試方法怎么做好公司官網推廣
  • 手機怎么做網站免費的百度學術官網入口
  • 電腦維修 做網站小廣告圖片
  • 網站建設系統(tǒng) 招標西安百度seo推廣電話
  • 濟寧做網站有哪幾家職業(yè)培訓機構需要什么資質
  • 招商平臺公司山西seo排名
  • 做棋牌推廣網站違法不網絡推廣站
  • 天津網站建設定制公司免費seo網站推廣在線觀看
  • 什么視頻網站可以做鏈接深圳網站開發(fā)公司
  • 商河做網站多少錢my77728域名查詢
  • 做網站要學多久電商運營
  • 為男人做購物網站攜程: 2023年旅行搜索上漲超900%
  • 網站建設招標公告首頁排名關鍵詞優(yōu)化
  • 鄭州網站建設方案書網絡的推廣