600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > rn webview加载本地静态html React Native - Webview 加载本地文件

rn webview加载本地静态html React Native - Webview 加载本地文件

时间:2023-05-25 06:55:26

相关推荐

rn webview加载本地静态html React Native - Webview 加载本地文件

网上没找到合适的方法。用react-native-fs解决了一下,因为release之后静态文件地址发生改变,之前的引入就无效了

1.项目根目录引入静态文件的文件夹

2.创建一个html,刚才引入的地址${RNFS.MainBundlePath}/web

/**

* ./EditorHtml

*/

let RNFS = require('react-native-fs');

const htmlWeb = `

`;

export default htmlWeb;

3.引入这个html${RNFS.MainBundlePath}/web

import WEBHTML from './EditorHtml';

4.注意baseUrl

scrollEnabled={false}

ref={webview => this.webview = webview}

onMessage={this.invoke.listener}

javaScriptEnabled={true}

automaticallyAdjustContentInsets = {false}

scalesPageToFit={true}

contentInset={{left : 0,right:0,top:0,bottom:0}}

source={{html:WEBHTML,baseUrl: '/web'}}

/>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。