CRoNiC
CRoNiC

Reputation: 409

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

If I want to display a local html file in a Webview, how can I do it?

Tried Solutions:

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" } },
               ...

both solutions lead to the following error: enter image description here Filestructure:
enter image description here

Upvotes: 0

Views: 256

Answers (1)

Yong
Yong

Reputation: 1127

Your path lacks of "app"

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

or

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

webpack config

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

Upvotes: 1

Related Questions