webview - 如何在 React Native 的 WebView 中使用源而不是 html

标签 webview react-native

最近,React Native 弃用了 htmlurl 属性,并将它们替换为 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/

相关文章:

javascript - 使用 Navigator 推送新路线时出现问题

android - 如何在 React Native WebView 中触发嵌入式 YouTube 视频播放的全屏模式?

java - Android:下载文件八位字节流 WebView

android - 如何从AccessibilityNodeInfo获取webview

reactjs - React 组件不对 mobx 可观察数据使用react

react-native - React Native Picker 可以在某些项目之间有某种分隔符或分隔符吗?

react-native - React redux 数据未成功传递

android - 在 WebView 上禁用双击缩放/取消缩放

Android WebView 性能

javascript - 将 StackNavigator 从 v4 转换为 v5 React Native 身份验证错误