在iOS上构建后,电容式离子WebView显示空白页面

a2mppw5e  于 2022-12-20  发布在  iOS
关注(0)|答案(1)|浏览(127)

我用的是离子电容器。构建后,iOS中的webview没有打开外部链接。xcode调试时没有错误或警告消息。但是,它在浏览器和Android上运行良好。我错过了什么?
在index.html中

<meta http-equiv="Content-Security-Policy"
    content="gap: wss: ws: ; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline';">

WebView配置:

import { InAppBrowser } from '@ionic-native/in-app-browser';
var browser = InAppBrowser.create( wpcUrl, "_blank",

    {
      location: 'no', //Or 'no' 
      hardwareback: 'yes',
      mediaPlaybackRequiresUserAction: 'yes',
      closebuttoncaption: 'Share', //iOS only
      disallowoverscroll: 'no', //iOS only 
      toolbar: 'yes', //iOS only 
      toolbarposition: 'bottom',
      enableViewportScale: 'no', //iOS only 
      allowInlineMediaPlayback: 'no', //iOS only 
      presentationstyle: 'formsheet', //iOS only 
    
    }
);

我也尝试了target _blank、_system和_self,但问题相同。
注意:我在它的根目录下没有任何config.xml文件,我只有一个manifest.json,看起来像这样:

{
  "short_name": "WPCafe App",
  "name": "My WPCafe App",
  "icons": [
    {
      "src": "assets/icon/favicon.png",
      "sizes": "64x64 32x32 24x24 16x16",
      "type": "image/x-icon"
    },
    {
      "src": "assets/icon/icon.png",
      "type": "image/png",
      "sizes": "512x512",
      "purpose": "maskable"
    }
  ],
  "start_url": ".",
  "display": "standalone",
  "theme_color": "#ffffff",
  "background_color": "#ffffff"
}
2hh7jdfx

2hh7jdfx1#

这是URL问题。您可以使用encodeURI方法对URL进行编码:

let url = encodeURI(YOUR_URL); 
 let browser = InAppBrowser.create(url, '_blank', InAppBrowserOptions);

相关问题