[英]How to show local html in React Native WebView without react-native-static-server or similar?
[英]How to show html in react native webView?
我正在使用 webView 来渲染一块 html 但不是渲染它而是显示代码。 问题是什么?
我的代码是...
<WebView
source = {scoLocal['sco']}
javaScriptCanOpenWindowsAutomatically={true}
javaScriptEnabled={true}
domStorageEnabled={true}
style={[styles.textArea, {
width: '100%',
height: '100%',
maxHeight: '100%',
maxWidth: '100%'
}]}
/>
也许您应该显示 scoLocal,这可能是您收到错误的原因。 一般用法如下所示。
<WebView
originWhitelist={['*']}
source={{ html: '<p>This is an HTML p tag</p>' }}
/>
或者
const htmlSource = '<p>This is an HTML p tag</p>'
<WebView
originWhitelist={['*']}
source={{ html: htmlSource }}
/>
有一个美好的!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.