【问题标题】:Nativescript App - load local HTML/JS/CSS in WebviewNativescript App - 在 Webview 中加载本地 HTML/JS/CSS
【发布时间】:2020-09-15 10:04:04
【问题描述】:

如果我想在 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" } },
               ...

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

【问题讨论】:

    标签: android webview nativescript


    【解决方案1】:

    您的路径缺少“应用程序”

    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/**"} }
    

    【讨论】:

      猜你喜欢
      • 2020-11-05
      • 1970-01-01
      • 2019-05-12
      • 2011-05-31
      • 2019-04-17
      • 2018-08-27
      • 1970-01-01
      • 2014-06-15
      • 2021-02-20
      相关资源
      最近更新 更多