【问题标题】:Export IndexedDB Database with Dexie in Quasar在 Quasar 中使用 Dexie 导出 IndexedDB 数据库
【发布时间】:2021-05-20 18:49:48
【问题描述】:

我正在尝试使用 dexie-export-import 在我的 Quasar 项目中使用 Dexie 导出我的 IndexedDB 数据库。我是 Quasar 和 Dexie 的新手,所以请原谅我缺乏知识。

我的代码似乎正在运行,并且我的控制台中没有出现错误,但我也没有看到导出任何内容。我想知道是否正在进行导出,但我不知道它的去向?

我正在通过 Electron 运行 Quasar,因为这将是一个桌面应用程序。

我还想知道我可能必须触发从 Quasar 下载文件?我很感激任何帮助。我一直在网上搜索,但找不到我做错了什么。

这是一个代码sn-p:

import {importDB, exportDB} from "dexie-export-import"

try {
  const blob = await exportDB(myDB)
  console.log("         in try ")
  return blob
} catch (error) {
  console.error(' error: '+error);
}

【问题讨论】:

    标签: javascript indexeddb quasar-framework dexie


    【解决方案1】:

    您需要向用户展示您获得的 blob。一种方法(也是使用on this codepen example 的方法)是使用download-js 并将blob 传递给它的download() 函数。这将为用户触发文件内容的“下载”。

      const blob = await exportDB(myDB)
      download(blob, "dexie-export.json", "application/json");
    

    【讨论】:

    • 感谢您的回复。当我添加 download(...) 行时,我收到一条错误消息“ManageExportImport.vue?ad38:74 error: ReferenceError: download is not defined”
    • 需要导入或包含download-js。
    猜你喜欢
    • 1970-01-01
    • 2021-10-15
    • 2018-08-13
    • 2020-03-30
    • 2020-06-22
    • 2011-12-09
    • 2019-06-17
    • 2021-06-24
    • 2017-11-17
    相关资源
    最近更新 更多