【问题标题】:NativeScript WebView not loading html fileNativeScript WebView 未加载 html 文件
【发布时间】:2019-08-29 05:36:31
【问题描述】:

尝试在我的本机脚本(打字稿)应用程序中将本地 HTML 文件加载到 webview 中。它没有加载,但显示错误。

<WebView src="~/assets/content.html" />

在此服务器上找不到请求的 URL。

【问题讨论】:

  • @AshishKamble 这是安卓版的吧?我的案例是关于 NativeScript。

标签: html typescript nativescript


【解决方案1】:

您必须传递绝对 URL,或者您可以尝试以下方法。

import * as fs from "tns-core-modules/file-system";
public webViewSRC: string = encodeURI(`${fs.knownFolders.currentApp().path}/assets/content.html`);

在你的 html 中

<WebView [src]="webViewSRC"></WebView>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-08-10
    • 2014-04-11
    • 1970-01-01
    • 2022-06-25
    • 1970-01-01
    • 1970-01-01
    • 2017-07-23
    相关资源
    最近更新 更多