NativeScript WebView not loading html file

送分小仙女□ 提交于 2021-01-29 18:44:50

问题


Trying to load a local HTML file into webview in my native-script (typescript) application. It's not loading but shows an error.

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

The requested URL was not found on this server.


回答1:


You have to pass the absolute URL or you can try the following.

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

and in your html

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


来源:https://stackoverflow.com/questions/57703601/nativescript-webview-not-loading-html-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!