簡體   English   中英

如何在反應原生 webView 中顯示 html?

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

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM