Cordova Inapp 浏览器抛出错误
Cordova Inapp browser throws error
当我使用 Cordova Inappbrowser (http://ngcordova.com/docs/plugins/inAppBrowser/)
时出现以下错误
TypeError: Cannot read property 'open' of undefined
$cordovaInAppBrowser.open(urlToGo, '_self', options)
.then(function(event) {
// success
console.log("Success...");
})
.catch(function(event) {
// error
console.log("Error...");
});
$cordovaInAppBrowser.close();
先尝试将您的代码封装到准备好的设备中;
document.addEventListener("deviceready", function () {
$cordovaInAppBrowser.open(urlToGo, '_self', options)
.then(function(event) {
// success
console.log("Success...");
})
.catch(function(event) {
// error
console.log("Error...");
});
$cordovaInAppBrowser.close();
}, false);
如果还是不行试试官方的cordova-plugin-inappbrowser。
我有时发现 ng 插件并不总是很好用。
他们的示例触发浏览器。
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
window.open = cordova.InAppBrowser.open;
}
当我使用 Cordova Inappbrowser (http://ngcordova.com/docs/plugins/inAppBrowser/)
时出现以下错误TypeError: Cannot read property 'open' of undefined
$cordovaInAppBrowser.open(urlToGo, '_self', options)
.then(function(event) {
// success
console.log("Success...");
})
.catch(function(event) {
// error
console.log("Error...");
});
$cordovaInAppBrowser.close();
先尝试将您的代码封装到准备好的设备中;
document.addEventListener("deviceready", function () {
$cordovaInAppBrowser.open(urlToGo, '_self', options)
.then(function(event) {
// success
console.log("Success...");
})
.catch(function(event) {
// error
console.log("Error...");
});
$cordovaInAppBrowser.close();
}, false);
如果还是不行试试官方的cordova-plugin-inappbrowser。 我有时发现 ng 插件并不总是很好用。
他们的示例触发浏览器。
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
window.open = cordova.InAppBrowser.open;
}