如何重新加载Cordova项目页面? [英] How to reload page on a Cordova project?

查看:618
本文介绍了如何重新加载Cordova项目页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用



  window.location。重新加载(真); 

它适用于浏览器窗口以及Cordova应用程序。


I am building an app, using polymer starter kit & cordova to wrap the project. Now, since I use firebase as a database for storing data, I ended up using two native firebase javascript function to find user data:

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.")
  }
});

Those two functions require a reload to bring back data from firebase, but :

window.location.reload();

doesn't work

Alos looked for a Cordova plugin: webview-reloader, installed it but redirect and reload still not working.

When i use the reload() function the screen of my android phone is going white and the application stop working. Need to close the app and open it again.

解决方案

Since Cordova is a wrapper around a browser window:

window.location.reload(true);

It works for the browser windows as well as a Cordova app.

这篇关于如何重新加载Cordova项目页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆