react native webview load from device local file system

后端 未结 5 1174
萌比男神i
萌比男神i 2020-12-07 21:08

I\'m trying to load .html, .js, .css files from device\'s local file system into React Native WebView component. I was able to get the

5条回答
  •  情深已故
    2020-12-07 21:48

    In react native it is now possible to require an HTML file and use it as the source for the web view like this (the path is relative to the react-native file you use it in):

    const webapp = require('./webapp/index.html');
    

    and the use it in the WebView like this:

    
    

    Unfortunately this does not load CSS and JavaScript files, that are referenced in the HTML. A solution could be, to write all the CSS and JS inline (e.g. by using a build process).

提交回复
热议问题