Load Local HTML/JavaScript/CSS Inside NativeScript App

回眸只為那壹抹淺笑 提交于 2019-12-02 04:43:13

问题


With a NativeScript iOS and Android app using Angular, how do I load, inside of a WebView, a locally stored html file that has JS and CSS references? I am able to display the WebView but I get the error that the file is not found because I do not know where to point the src from my component.

Currently I have the files inside src/assets and in there is the index.html

Is there a more appropriate place to store these files within the app? Is there a better way to display this than a WebView? How do I reference this file as the source of a WebView?

I will also be needing to know how to reference a file the app downloads. Where does iOS and Android store downloaded files from within the app? How do i reference these files from my WebView?

Thank you.


回答1:


You have to use absolute path while importing local JS / CSS / Image into WebView. Here is a Playground sample. Unlike the given example if you want to load files those are packed with app, simply use app directory instead with right path to file.



来源:https://stackoverflow.com/questions/53732871/load-local-html-javascript-css-inside-nativescript-app

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