How to load a local html file into a NativeScript webview

我只是一个虾纸丫 提交于 2020-06-09 06:47:15

问题


I have modified the webpack.config.js to add a local file called index.html the code below :

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

This is how I configured my webview in the main-page.xml file the code below:

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

回答1:


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.



来源:https://stackoverflow.com/questions/60760372/how-to-load-a-local-html-file-into-a-nativescript-webview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!