Javascript 启用ionic 3 firestore的脱机功能
你能帮我先让我的爱奥尼亚3应用程序离线吗。我正在为web、android、ios和windows phone创建单一代码。我需要启用脱机功能。谷歌文档上说要使用下面的代码 但是我不确定在哪里添加下面的代码,我使用environment.ts文件进行配置,在app.component.ts文件的构造函数中,我包含了下面的代码Javascript 启用ionic 3 firestore的脱机功能,javascript,ionic-framework,google-cloud-firestore,offline,Javascript,Ionic Framework,Google Cloud Firestore,Offline,你能帮我先让我的爱奥尼亚3应用程序离线吗。我正在为web、android、ios和windows phone创建单一代码。我需要启用脱机功能。谷歌文档上说要使用下面的代码 但是我不确定在哪里添加下面的代码,我使用environment.ts文件进行配置,在app.component.ts文件的构造函数中,我包含了下面的代码 firebase.firestore().enablePersistence().then(function() { // Initialize Cloud Firest
firebase.firestore().enablePersistence().then(function() {
// Initialize Cloud Firestore through firebase
var db = firebase.firestore();
}).catch(function(err) {
if (err.code == 'failed-precondition') {
// Multiple tabs open, persistence can only be enabled
// in one tab at a a time.
// ...
} else if (err.code == 'unimplemented') {
// The current browser does not support all of the
// features required to enable persistence
// ...
}
}))
我的第一个疑问是,我应该将这些代码粘贴到哪里,我是否需要添加更多的代码来启用脱机持久性,或者这就足够了
第二个问题是,我是否需要针对不同的平台采用不同的方法,比如android,需要遵循firestore文档中的android教程以及针对不同的web应用程序。或者启用web将自动适用于其他平台,如ios、android和web
另外,当我在app.component.ts的构造函数中使用上述代码时,我得到了下面的错误
WEBPACK_IMPORTED_MODULE_5_firebase___default.a.firestore is not a function
堆栈是:
TypeError:\网页包\导入的\模块\ 5\ firebase\默认值。a.firestore不是函数
在新的MyApp()上
在此处输入代码
在createClass()
在createDirectiveInstance()上
在createViewNodes()处
在createRootView()上
在callWithDebugContext()处
在Object.debugCreateRootView[作为createRootView]
谢谢您找到解决方案了吗?