我很难理解这个错误。Uncaught TypeError: PouchDB is not constructor: PouchDB不是一个构造函数
代码如下。
var PouchDB = require("pouchdb");
var db = new PouchDB("scr");
我读到过关于它可能与类型有关的信息 I've read about how it may be related to types and that adding:
"@types/node": "^10.12.0",
"@types/pouchdb": "^6.3.2",
添加到我的package.json中应该会有帮助,但它没有。我在另一个简单的.js文件上进行了测试,工作正常,但在我的主应用程序上却不行。不过,我还是不明白为什么它不能工作。小袋的文档很清楚 https:/pouchdb.comapi.html#create_document。.
我应该提到,我是在电子应用的上下文中运行的,而不是在浏览器中。
在这一点上,我很困惑,任何帮助将是非常感激的。干杯
对于没有构造函数的使用.default
const PouchDB = require('pouchdb').default;