【发布时间】:2015-12-29 08:14:12
【问题描述】:
我正在构建一个应用程序,使用 polymer starter kit 和 cordova 来包装项目。现在,由于我使用firebase 作为存储数据的数据库,我最终使用了两个原生的firebase javascript 函数来查找用户数据:
getAuth()
var ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com");
var authData = ref.getAuth();
if (authData) {
console.log("Authenticated user with uid:", authData.uid);
}
onAuth()
var ref = new Firebase("https://<YOUR-FIREBASE-APP>.firebaseio.com");
ref.onAuth(function(authData) {
if (authData) {
console.log("Authenticated with uid:", authData.uid);
} else {
console.log("Client unauthenticated.")
}
});
这两个函数需要重新加载才能从 firebase 中取回数据,但是:
window.location.reload();
没用
Alos 寻找了一个 Cordova 插件:webview-reloader,安装了它,但重定向和重新加载仍然无法正常工作。
当我使用 reload() 函数时,我的安卓手机屏幕变白,应用程序停止工作。需要关闭应用并重新打开。
【问题讨论】:
-
你试过
document.location = 'index.html'吗? stackoverflow.com/a/8506527 -
确实尝试了 document.location = 'index.html' 并抛出错误,说他找不到文件位置
标签: javascript android cordova firebase