美文网首页
react-native webView根据内容调整自身高度

react-native webView根据内容调整自身高度

作者: 早起的小孩没饭儿吃 | 来源:发表于2016-10-28 21:18 被阅读2349次

参考:https://www.zhihu.com/question/42864534

<WebView javaScriptEnabled={true} source={{ html: HTML }} style={{ height: this.state.WebViewHeight,width:Width }} onNavigationStateChange={(info)=>{ this.setState({WebViewHeight:info.url.replace('about:blank%23','')/1 + 20 }) }} scrollEnabled={false} />
window.onload = function(){ var height = document.body.clientHeight; window.location.hash = '#' + height; }
这只是一个思路,这里有一个Github项目GitHub - alinz/react-native-webview-bridge: React Native Webview with Javascript Bridge**可以让WebView和React的JS进行通信。

作者:刘开链接:https://www.zhihu.com/question/42864534/answer/115386718来源:知乎著作权归作者所有,转载请联系作者获得授权。

相关文章

网友评论

      本文标题:react-native webView根据内容调整自身高度

      本文链接:https://www.haomeiwen.com/subject/wlveuttx.html