这就是我对 PouchDB 和 Ionic 2 rc0 所做的。
npm install --save pouchdb 安装 PouchDB
npm install --save @types/pouchdb 安装 PouchDB 分型
然后,在您的代码中,您必须导入 PouchDB:
import PouchDB from 'pouchdb';
初始化你的数据库:
this.db = new PouchDB( 'myDB', {adapter: 'websql'} );
如果您需要将您的数据库与本地 CouchDB 服务器同步(查看您的 PouchDB 数据库内容非常有用):
this.remote = 'http://localhost:5984/myDB';
let options = {
live: true,
retry: true,
continuous: true
};
this.db.sync( this.remote, options );
如果还是不行,再试试:
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
祝你好运,因为 Ionic 2 rc0 是目前编译(构建)的噩梦......
Ionic 团队正在努力解决编译问题,但仍然很糟糕......