[英]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.