问题
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