本人也是react native的菜鸟,下面只是说说解决方案,具体为什么可以实现目前还不懂。
我在项目里因为需求关系,在ScrollView里放置了WebView。
方法一:
一开始我按照网上的一些方法在js里的代码如下:
12 <WebView 3 ref={'webview'} 4 source={{ html: data.html }} 5 style={{ height: this.state.WebViewHeight }} 6 scrollEnabled = {false} 7 onNavigationStateChange={(title)=>{ 8 this.setState({ 9 WebViewHeight: (parseInt(title.title)) 10 }) 11 }} 12 onMessage={(e) => { 13 this.handleMessage(e) 14 }} 15 /> 16 ... 17
在data.html里的代码如下:
1 2 3 4 5 6 7 ... 8 9 15 16