运行 Ionic + React + Capacitor 环境中的 InAppBrowser
run InAppBrowser in an Ionic + React + Capacitor environment
我对这项技术完全陌生,我无法从 @ionic-native/in-app-browser
中 运行 InAppBrowser
。我已经安装了相应的插件,但它似乎无法在实际的本机应用程序中运行。这是我的代码:
import { InAppBrowser, InAppBrowserOptions } from "@ionic-native/in-app-browser";
const websiteUrl: string = "https://a-working-url.com"
const options: InAppBrowserOptions = {
zoom: 'no',
location: 'no',
toolbar: 'no',
hidden: 'yes',
hideurlbar: 'yes',
toolbarposition: 'bottom'
}
const browser = InAppBrowser.create(websiteUrl, '_self', options)
browser?.on('loadstop').subscribe(event => {
browser.insertCSS({ code: "body{color: red; padding: 10mm;" });
console.log('loadstop DONE!')
});
我在 Android 日志中收到以下消息:
Msg: Native: InAppBrowserOriginal is not installed or you are running
on a browser. Falling back to window.open.
我错过了什么?
注意:@capacitor/core
我不使用Browser
的原因是我不能让浏览器隐藏它的导航栏,而且不支持insertCSS
这是我真正需要的。
好的,问题已解决。我注意到插件没有正确安装..
我不得不通过以下方式重新安装插件:
npm install cordova-plugin-inappbrowser
我对这项技术完全陌生,我无法从 @ionic-native/in-app-browser
中 运行 InAppBrowser
。我已经安装了相应的插件,但它似乎无法在实际的本机应用程序中运行。这是我的代码:
import { InAppBrowser, InAppBrowserOptions } from "@ionic-native/in-app-browser";
const websiteUrl: string = "https://a-working-url.com"
const options: InAppBrowserOptions = {
zoom: 'no',
location: 'no',
toolbar: 'no',
hidden: 'yes',
hideurlbar: 'yes',
toolbarposition: 'bottom'
}
const browser = InAppBrowser.create(websiteUrl, '_self', options)
browser?.on('loadstop').subscribe(event => {
browser.insertCSS({ code: "body{color: red; padding: 10mm;" });
console.log('loadstop DONE!')
});
我在 Android 日志中收到以下消息:
Msg: Native: InAppBrowserOriginal is not installed or you are running on a browser. Falling back to window.open.
我错过了什么?
注意:@capacitor/core
我不使用Browser
的原因是我不能让浏览器隐藏它的导航栏,而且不支持insertCSS
这是我真正需要的。
好的,问题已解决。我注意到插件没有正确安装.. 我不得不通过以下方式重新安装插件:
npm install cordova-plugin-inappbrowser