2017-01-06 137 views
1

我想以编程方式重新启动我的Ionic应用程序。以编程方式重新启动离子应用程序

我发现解决方案只重新加载当前视图,如location.reload() ...但我希望应用程序重新运行app.js,iOS和Android都可以。

有什么想法? 谢谢

+0

闪屏app.js这个答案请看:http://stackoverflow.com/a/37837377/ 1697755 – Schlaus

+0

如果您想要关闭应用程序并重新打开它,我认为您运气不佳; http://stackoverflow.com/questions/18707914/jquery-mobile-programatically-reinitialise-restart-app(查看接受的答案) – opt05

+0

iOS不可能 – Gruntcakes

回答

2

我不会推荐使用这种方法,单页面应用程序总是尝试让系统重置数据,缓存,历史记录等,然后进入初始状态,而不是强制刷新de webUI。 Ionic有许多功能可以帮助您实现这一目标。

0

尝试这种解决方案

var initialHref = window.location.href; 
navigator.splashscreen.show(); 
// Reload original app url (ie your index.html file) 
window.location = initialHref; 
navigator.splashscreen.hide(); 

,或者你可以躲在里面

.run(function(){ 
    $ionicPlatform.ready(function() { 
      if (cordova.platformId === 'ios' && window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) { 
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); 
      cordova.plugins.Keyboard.disableScroll(true); 
     } 
     if (window.StatusBar) {  
      StatusBar.styleDefault(); 
     } 
    navigator.splashscreen.hide(); 
}) 
相关问题