问题
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