当前位置: 首页 > news >正文

公众号怎么制作微信红包封面seo教学网seo

公众号怎么制作微信红包封面,seo教学网seo,经营性网站备案需要什么,wordpress 搜索文章Vue使用 IndexDB vue操作IndexDB数据库 Vue操作IndexDB数据库 Vue使用 IndexDB vue操作IndexDB数据库 Vue操作IndexDB数据库安装 IndexDB类库引入 localForage测试 新增数据、获取数据 Vue使用 IndexDB vue操作IndexDB数据库 Vue操作IndexDB数据库 大部分场景使用 LocalStore都…

Vue使用 IndexDB vue操作IndexDB数据库 Vue操作IndexDB数据库

  • Vue使用 IndexDB vue操作IndexDB数据库 Vue操作IndexDB数据库
    • 安装 IndexDB类库
    • 引入 localForage
    • 测试 新增数据、获取数据

Vue使用 IndexDB vue操作IndexDB数据库 Vue操作IndexDB数据库

大部分场景使用 LocalStore都足够了,但是 如果要考虑大数据的话,LocalStore支持并不是很好,有内存限制,并且数据过大 LocalStore解析和存储性能不是很好,这时候可以使用 IndexDB,数据格式 是和 数据库一样,可以创建多个数据库,数据库里面有多个表

安装 IndexDB类库

原生 IndexDB操作API并不是很方便,可以使用第三方类库,可以极大的减少工作量,调用IndexDB和LocalStore API很像,我这边使用过的是 LOCALFORAGE 官网

支持存储类型有:
在这里插入图片描述

npm

npm install localforag

或者 使用 yrm

yarn add localforage

引入 localForage

main.js 中引用

import Vue from 'vue'
import App from './App'
import router from './router'// IndexDB封装类库 https://localforage.github.io/localForage/#installation
import localforage from 'localforage'Vue.use(localforage)// 将 localforage 挂载到全局示例, 这样就可以在任何地方 用 this.$localforage 操作
Vue.prototype.$localforage = localforageconsole.info('localforage初始化成功,使用 this.$localforage 调用')// 创建一个 默认的 IndexDB数据库挂载到全局
const demoDataBase = localforage.createInstance({name: 'demoDataBase'
})Vue.prototype.$demoDataBase  = demoDataBase 
console.info('默认数据库 demoDataBase  初始化成功,使用 this.$demoDataBase 调用')Vue.config.productionTip = falsenew Vue({el: '#app',router,components: { App },template: '<App/>'
})

测试 新增数据、获取数据

在 demoDataBase数据库新增一条数据

    // 操作 demoDataBase数据库this.$demoDataBase.setItem('测试demoDataBase', '我是测试值').then(function (value) {// Do other things once the value has been saved.console.log(value)}).catch(function (err) {// This code runs if there were any errorsconsole.log(err)})// 不需要回调this.$demoDataBase.setItem('测试demoDataBase2', '我是测试值2')

查看是否生效,数据已经新增上去了,一共两条

在这里插入图片描述

获取数据也很简单

    // 操作 demoDataBase数据库this.$demoDataBase.getItem('测试demoDataBase').then(function (value) {// Do other things once the value has been saved.console.log(value)}).catch(function (err) {// This code runs if there were any errorsconsole.log(err)})// 不需要回调this.$demoDataBase.getItem('测试demoDataBase2')

还有删除、查询等更多API不一一演示了,可以进入官网 查看更多

http://www.hengruixuexiao.com/news/19011.html

相关文章:

  • 做的网站客户拿去维违法餐饮培训
  • 崇左做网站公司百度网站
  • 1m带宽做网站快不新闻头条最新
  • wordpress幻灯片滚动插件菏泽seo
  • 做网站的框架结构百度自媒体怎么注册
  • 动态网页设计作业成品在线seo关键词排名优化
  • wordpress 导出html5360优化大师官方免费下载
  • 用Html5做网站企业培训课程推荐
  • 做网站gif代码上海seo招聘
  • 泰安网络诈骗网上报警seo在线教程
  • 一站式网站建设平台免费下载百度一下
  • 西安网站建设报价方案打开百度搜索
  • 做礼品公司网站的费用精准引流推广公司
  • 做一个大型网站需要多少钱中国十大营销策划公司排名
  • 安徽手机版建站系统信息湖北seo诊断
  • a站b站搭建网站需要哪些步骤
  • 网站群管理建设帮人推广的平台
  • 外贸工厂 网站建设web设计一个简单网页
  • 做网站公司关键词成免费crm特色
  • 怎么建设淘宝联盟的网站谷歌seo和百度seo
  • proudly powered by wordpress站长之家seo综合
  • 好的网站设计网络营销的模式有哪些
  • 梁平区高点击量网站建设哪家好短期的技能培训有哪些
  • 太原建立网站百度网盘资源搜索引擎
  • 嘉兴专业做网站的公司附近的教育培训机构有哪些
  • 做高效能的父母网站中级经济师考试
  • 制作宝安网站建设网络推广seo怎么弄
  • 郑州做网站好2023年5月最新疫情
  • 网站 验收一键优化软件
  • 网站建设流程 费用百度问问首页