【问题标题】:IONIC using inappbrowser loadstart not workingIONIC 使用 inappbrowser loadstart 不工作
【发布时间】:2017-03-30 05:05:27
【问题描述】:

IONIC 使用 inappbrowser 不工作

var ref=   $cordovaInAppBrowser.open(url, '_self', options);        
ref.addEventListener('loadstart', function(event) {  
    alert(event.url); $ionicLoading.show() 
}); 
ref.addEventListener('loadstop', function(event) {  
    alert(event.url); 
    $ionicLoading.hide() 
});

【问题讨论】:

    标签: ionic-framework inappbrowser


    【解决方案1】:

    试试:

    $ionicLoading.show();
    $cordovaInAppBrowser.open(url, '_blank', inAppBrowserOptions);
      $rootScope.$on('$cordovaInAppBrowser:loadstop', function(e, event){
        $cordovaInAppBrowser.show();
        $timeout(function(){$ionicLoading.hide()},2000);
      });
    

    对于 inAppBrowserOptions:

      .config(function($cordovaInAppBrowserProvider) {
        var defaultOptions = {
          location: 'yes',
          clearcache: 'no',
          hardwareback: 'yes',
          toolbar: 'no'
        };
        document.addEventListener("deviceready", function () {
          $cordovaInAppBrowserProvider.setDefaultOptions(defaultOptions)
        }, false);
      });
    

    【讨论】:

    • 我需要在打开外部 URL 时显示加载器
    • 在下载外部 URL 之前显示加载器是否不可行。作为当前的解决方案,打开加载器,但是在打开外部 URL 时会显示空白屏幕
    • 如果此解决方案按照建议的方式实施,它会为您提供加载图标,同时在后台加载浏览器并在调用 $ionicLoading.hide() 后立即显示它。请检查您是否缺少任何东西!
    • 谢谢,我忘了提到选项[隐藏到是]
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多