【问题标题】:Using pouchdb in Ionic 2 RC.0在 Ionic 2 RC.0 中使用 pouchdb
【发布时间】:2016-10-15 09:57:14
【问题描述】:

我正在尝试使用 pouchdb 为 Ionic 2 RC.0 调整同步数据: http://www.joshmorony.com/syncing-data-with-pouchdb-and-cloudant-in-ionic-2/for

我已经安装了 pouchdb:

npm install pouchdb

data.ts文件中导入:

import pouchdb from 'pouchdb';

但是我无法使用它this.db = new pouchdb('abc');

屏幕上没有显示任何内容。

【问题讨论】:

    标签: javascript angular ionic2 pouchdb


    【解决方案1】:

    这就是我对 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 团队正在努力解决编译问题,但仍然很糟糕......

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-09
      • 2017-02-10
      • 2017-02-13
      • 2017-04-08
      • 2017-02-11
      • 2016-11-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多