NativeScript WebView not loading html file(NativeScript WebView未加载html文件)
问题描述
正在尝试将本地HTML文件加载到本机脚本(TypeScript)应用程序的WebView中。它未加载,但显示错误。<WebView src="~/assets/content.html" />
在此服务器上找不到请求的URL。
推荐答案
您必须传递绝对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>
这篇关于NativeScript WebView未加载html文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!