React native 如何在本地Android的发布包中包含静态html?
我有一个WebView,它使用本地文件React native 如何在本地Android的发布包中包含静态html?,react-native,react-native-android,React Native,React Native Android,我有一个WebView,它使用本地文件require来显示web内容 <WebView source={ require('./inline_web_view/inline_web_view.html') } injectedJavaScript={ scripts } scrollEnabled={ this.props.scrollEnabled || false } scalesPageToFit={ false } style={{
require
来显示web内容
<WebView
source={ require('./inline_web_view/inline_web_view.html') }
injectedJavaScript={ scripts }
scrollEnabled={ this.props.scrollEnabled || false }
scalesPageToFit={ false }
style={{
width: this.state.width,
height: this.state.height,
}}
onNavigationStateChange={ (navState)=> this.onNavigationStateChange(navState) }
/>
this.onNavigationStateChange(navState)}
/>
在开发模式下,这在ios和Android上非常有效,但是,似乎Android发行包中没有包含HTML文件
如何将其添加到捆绑包中?这是React Native中的一个已知问题
快速解决方法是在iOS和Android中以不同的方式加载内容。iOS将如您所述工作,但对于Android版本,您需要将静态文件复制到本机应用程序资产文件夹(即Android/app/src/main/assets)中,并使用
{uri:'加载内容file:///android_asset/-your-path-“}
源代码
有关完整详细信息和完整示例,请参阅。{uri:'file:///android_asset/-your-path-“}//android_资产上没有S