首页 > 解决方案 > UWP 应用程序 webview Aurelia Polyfill 抛出错误

问题描述

当前从 UWP 应用程序运行 web 视图,当我尝试在 index.html 中运行 polyfill 脚本时,出现来自 Aurelia 的 polyfill.js 文件的“未处理的承诺拒绝:未指定错误”的错误。

自新的 Windows 10 更新以来,这只是最近的一个问题

因为polyfill失败,页面加载失败

尝试包含另一个名为 polyfill.io 的 polyfill 库,但仍然失败

我只是在 index.html 中运行它

<body>
    <div class="#####" aurelia-app="main">
        <div class="loading">
          <div class="cloud"></div>
        </div>

      <script src="{{####}}/dist/vendor-bundle.js"></script>
      <script src="{{####}}/dist/polyfill-bundle.js"></script>
      <script src="{{####}}/dist/app-bundle.js"></script>
    </div>
  </body>

这是我在 UWP webview 中遇到的错误

polyfill-bundle.js (1,71003)

[object Error]: {description: "Unspecified error.", message: "Unspecified error.", number: -2147467259, 
stack: "Error: Unspecified error. at Anonymous function 
(#####/dist/vendor-bundle.js:54:39348) at Anonymous function 
(#####/dist/vendor-bundle.js:93:664043) at Array.prototype.forEach (native code) at a.PLATFORM.eachModule 
(#####/dist/vendor-bundle.js:93:663974) at e.get 
(#####/dist/vendor-bundle.js:54:39233) at e.prototype.load 
(#####/dist/vendor-bundle.js:93:746777) at Anonymous function 
(#####/dist/vendor-bundle.js:93:4153532) at Array.prototype.map (native code) at l 
(#####/dist/vendor-bundle.js:93:4153479) at Anonymous function 
(#####/dist/vendor-bundle.js:93:4169836)"}

标签: uwppolyfillsaurelia

解决方案


从错误消息中,您的 polyfill 脚本正在请求权限。

WebView 默认拒绝权限请求,但是你可以通过监听WebView.PermissionRequested事件来允许权限请求。

private void WebView_PermissionRequested(WebView sender, WebViewPermissionRequestedEventArgs args)
{
    args.PermissionRequest.Allow();
}

此致。


推荐阅读