2017-01-06 189 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(); 
}) 
相關問題