【发布时间】:2017-09-19 04:15:41
【问题描述】:
我为 Ionic Cordova 安装了 inAppBrowser 插件(至少我认为我安装正确。我按照这里的说明进行操作:https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-inappbrowser/#installation)。
我将 inAppBrowser 导入我的 app.module.ts 文件并将其添加到提供者列表中:
import { InAppBrowser } from '@ionic-native/in-app-browser';
和
providers: [
StatusBar,
SplashScreen,
InAppBrowser,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
我也像这样将它注入到相关页面中:
export class AboutPage {
options : InAppBrowserOptions = {
location : 'yes',
hidden : 'no',
clearcache : 'yes',
clearsessioncache : 'yes',
zoom : 'yes',//Android only
hardwareback : 'yes',
mediaPlaybackRequiresUserAction : 'no',
shouldPauseOnSuspend : 'no', //Android only
closebuttoncaption : 'Close', //iOS only
disallowoverscroll : 'no', //iOS only
toolbar : 'yes', //iOS only
enableViewportScale : 'no', //iOS only
allowInlineMediaPlayback : 'no',//iOS only
presentationstyle : 'pagesheet',//iOS only
fullscreen : 'yes',//Windows only
};
constructor(public navCtrl: NavController, public navParams: NavParams, private theInAppBrowser: InAppBrowser) {
}
public openWithSystemBrowser(url : string){
let target = "_system";
this.theInAppBrowser.create(url,target,this.options);
}
public openWithInAppBrowser(url : string){
let target = "_blank";
this.theInAppBrowser.create(url,target,this.options);
}
public openWithCordovaBrowser(url : string){
let target = "_self";
this.theInAppBrowser.create(url,target,this.options);
}
ionViewDidLoad() {
console.log('ionViewDidLoad AboutPage');
}
}
然后我在 html 页面中添加了一个按钮:
<button ion-button (click)="openWithSystemBrowser('https://www.preachingfriars.org')">Visit our site</button>
它似乎在 Android 中运行良好,但在 iOS 中没有运气。当我单击按钮时,什么都没有发生。我已经在论坛上搜索了几天,但仍然无法使其正常工作。如果您能提供任何帮助,我将不胜感激!
谢谢! 布伦特
【问题讨论】:
-
这个问题解决了吗?
-
不。我完全放弃了 Ionic,转而使用 phonegap。
标签: cordova ionic-framework inappbrowser