2016-12-16 90 views
3

我正在使用Ionic 2並試圖用cordova InAppBrowser打開外部鏈接。離子2 InAppBrowser網址無法打開

launch(url) { 
    this.platform.ready().then(() => { 
    InAppBrowser.open(url, "_system", "location=yes"); 
    console.log("link viewed"); 
    }); 
} 

但是,當我在手機上測試應用程序時,這並未打開鏈接。此外,當我把它改成這樣cordova.InAppBrowser.open(url, "_system", "location=yes");其與語法錯誤說找不到cordova

window.open(url, "_system", "location=yes");工作正常的瀏覽器返回它返回在控制檯Your current usage of the InAppBrowser plugin is depreciated as of [email protected] Please check the Ionic Native docs for the latest usage details.

任何人都知道更新的方式讓InAppBrowser打開?

回答

2

經過幾個小時,深入瞭解文件,我發現原因。

launch(url) { 
    this.platform.ready().then(() => { 
    new InAppBrowser(url, "_system", "location=yes"); 
    console.log("link viewed"); 
    }); 
} 
+0

lols我發現在2個薄荷糖中。 –

+0

是的,我只發現了以前的語法離子2以前仍在開發中 – SGhaleb

+1

良好的工作繼續下去...請改善您的答案,然後我會刪除我的一個 –

2

InAppBrowser

安裝命令

$ ionic plugin add cordova-plugin-inappbrowser 

使用

import {InAppBrowser} from 'ionic-native'; 
let browser = new InAppBrowser('https://ionic.io', '_system'); 

這裏是official documentation