如何将本地HTML文件加载到NativeScript Web视图中 [英] How to load a local html file into a NativeScript webview

查看:226
本文介绍了如何将本地HTML文件加载到NativeScript Web视图中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经修改了webpack.config.js,以添加一个名为index.html的本地文件,其代码如下:

new CopyWebpackPlugin([
    { from: { glob: "index.html" } },
    { from: { glob: "fonts/**" } },
    { from: { glob: "**/*.jpg" } },
    { from: { glob: "**/*.png" } },
 ], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
new nsWebpack.GenerateNativeScriptEntryPointsPlugin("bundle"),

这是我在main-page.xml文件中配置我的Web视图的以下代码:

<WebView row="1" loaded="onWebViewLoaded" id="myWebView" src="index.html"/>

推荐答案

在NativeScript中,默认情况下,代字号(~)标记应用程序的根文件夹(请注意应用程序而不是项目!).因此,如果您的文件位于<project-name>/app/index.html中,请尝试使用~/index.html设置路径.

In NativeScript, by default, the tilde (~) marks the app root folder (note the App and not the Project!). So if your file is located in <project-name>/app/index.html try setting the path with ~/index.html.

这篇关于如何将本地HTML文件加载到NativeScript Web视图中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆