1.通过WebView中的onNavigationStateChange属性进行高度的改变,通过更改属性值进行高度的改变
https://blog.csdn.net/YanceChen2013/article/details/77151208
https://flexwork.io/blog/webview-height-html-content-react-native/
2.webview android端html乱码问题
https://blog.csdn.net/TianciZhu/article/details/78827221
<WebView style={{ width: width - 60, height: 310 * KAdaptionHeight }}
scalesPageToFit={isTrue}
bounces={false}
source={{ html: content.content, baseUrl: '' }}// baseUrl: ''中文乱码解决
/>
3.webview ios侧边滑动条隐藏问题
<Webview style={{backgroundColor: 'transparent'}} .../>
4.webview html标签不完整问题
将属性source={{ html: <!DOCTYPE html><html><body>${initHtml}<script>window.onload=function(){window.location.hash = 1;document.title = document.body.clientHeight;}</script></body></html>
, baseUrl: '' }}
<WebView
ref={ref => this.webView = ref}
automaticallyAdjustContentInsets={false}
source={{ html: `<!DOCTYPE html><html><body>${initHtml}<script>window.onload=function(){window.location.hash = 1;document.title = document.body.clientHeight;}</script></body></html>`, baseUrl: '' }}
// onNavigationStateChange={(event)=>{console.log(event)}}
javaScriptEnabled={true}
domStorageEnabled={false}
decelerationRate="normal"
messagingEnabled={true}
scalesPageToFit={true}
style={{flex: 1}}
/>
5.webview html img标签无样式导致大图超出视图问题
修改原html标签
const initHtml = originalHtml.replace(new RegExp("<img", "gm"), "<img width=\"100%\" height=\"auto\" ")
网友评论