ionic2 中 Firefox 控制台访问所需的模块

Firefox console access required module in ionic2

我有一个非常简单的 Ionic2 项目,其中包含一些导入 pouchdb 库的供应商。

import * as PouchDB from 'pouchdb';

我想以某种方式从控制台访问 pouchdb。我怎样才能让它工作?

I want to access pouchdb from the console somehow.

假设您通过 运行

安装了 pouchdb 依赖项
npm install pouchdb --save

然后(可选但推荐)安装类型

npm install -g typings
typings install --global --save dt~pouchdb dt~pouchdb-adapter-websql dt~pouchdb-browser dt~pouchdb-core dt~pouchdb-http dt~pouchdb-mapreduce dt~pouchdb-node dt~pouchdb-replication

就像你说的,你需要在你的代码中引入它

import * as PouchDB from 'pouchdb';

然后使用new PouchDB('aName')方法获取数据库实例。然后你就可以在控制台中使用那个实例了。

@Injectable()
export class MyDbClass {

  db: any;

  constructor() {
    this.initializeDb();
  }

  initializeDb(){
    this.db = new PouchDB('aName');
    console.log(this.db);
  }