最近,React Native 弃用了 html
和 url
属性,并将它们替换为 source
。
<WebView
automaticallyAdjustContentInsets={false}
contentInset={{top: 0, right: 0, bottom: 0, left: 0}}
html={"<style>*{margin:0;padding:0;}canvas{position:absolute;transform:translateZ(0);}</style><canvas></canvas><script>var canvas = document.querySelector('canvas');(" + renderString + ").call(" + contextString + ", canvas);</script>"}
opaque={false}
underlayColor={'transparent'}
style={this.props.style}
javaScriptEnabled={true}
/>
如何将 html
替换为 source
。只是更换并不能解决问题。提前致谢。
最佳答案
<WebView source={{ html: "<h1>Hello</h1>" }} />
此处提供文档:http://facebook.github.io/react-native/docs/webview.html#content
关于webview - 如何在 React Native 的 WebView 中使用源而不是 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35741853/