Nativescript 应用程序 - 在 Webview 中加载本地 HTML/JS/CSS

Nativescript App - load local HTML/JS/CSS in Webview

如果我想在 Webview 中显示本地 html 文件,我该怎么做?

尝试过的解决方案:

this.htmlPath = encodeURI(`${fs.knownFolders.currentApp().path}/monitordaten/webview/assets/graph.html`); 
<Webview #myWebView [src]="htmlPath" ></Webview>
new CopyWebpackPlugin([
               { from: { glob: "monitrodaten/webview/assets/**"} },          <= Added this row
               { from: { glob: "fonts/**" } },
               { from: { glob: "**/*.jpg" } },
               ...

两种解决方案都会导致以下错误: 文件结构:

您的路径缺少“app”

this.htmlPath = encodeURI(`${fs.knownFolders.currentApp().path}/app/monitordaten/webview/assets/graph.html`); 

this.htmlPath = encodeURI(`~/app/monitordaten/webview/assets/graph.html`);

webpack 配置

{ from: { glob: "app/monitrodaten/webview/assets/**"} }