本文介绍了如何使用Angular-Cli / Webpack导入PouchDb-Find的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将Angular 2 / Typescript与PouchDb和PouchDb-Find一起使用,并通过Angular-cli(现在基于Webpack)生成一个项目。PouchDb通过简单的import语句进行连接。

I'm want to use Angular 2/Typescript with PouchDb and PouchDb-Find with a project generated with Angular-cli (which is now webpack based.) PouchDb gets wired in with a simple import statement.

c

var commonDb = new PouchDB(this.commonDbUrl) ;
console.log("commonDb",commonDb) ;

// .getIndexes() is from pouchDb.find. I don't know what the import for it is
commonDb.getIndexes().then(function (result) {
    console.log("GetIndexes.Success",result) ;
}).catch(function (err) {
    console.log("GetIndexes.Failed",err) ;
});

新的PouchDb有效,commonDb.getIndexes无效。我已经尝试过许多 import *的变体,例如从'pouchdb-find'到pouchfind都无济于事。

The new PouchDb works, the commonDb.getIndexes does not. I've tried many variations on import * as pouchfind from 'pouchdb-find' to no avail.

如何导入PouchDb查找模块吗?

How do I import the PouchDb-Find module?

推荐答案

我怀疑我无法以预期的方式解决此问题因为Angular-Cli仍处于beta中,并且肯定存在一些问题。

I suspect that I wasn't able to resolve this problem in the expected way because Angular-Cli is still in beta and there must be some issues.

我能够通过将pouchdb.find.js和poucdb.js放在 public / pouchdb 文件夹,然后从index.html引用它们,如下所示。我很清楚这是可以解决的,并且需要解决。

I was able to resolve the problem by putting pouchdb.find.js and poucdb.js in the public/pouchdb folder and referencing them from index.html as in the following. I'm well aware that this is a work around and will require a work around.

<script src="pouchdb/pouchdb.js"></script>
<script src="pouchdb/pouchdb.find.js"></script>

<script>
    PouchDB('pouchdbfind') ;
</script>

I我希望Angular-cli能够迅速成熟。

I'm hopeful Angular-cli will mature quickly.

这篇关于如何使用Angular-Cli / Webpack导入PouchDb-Find的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 04:07