react-native webview 没有出现

标签 react-native webview

出于某种原因,我的 react-native webview 根本没有出现。在我的文本字段之后没有任何显示。这是我的代码

import React, { Component } from 'react';


import {
View,
Text,
WebView,

} from 'react-native';


export default class Home extends Component {

    render() {
        return (
        <View style={{flexDirection:'column'}}>
          <Text>Show webview</Text>
          <WebView source={{html:"<html><body style='color:red'>Hello<br/>This is a test</body></html>"}} style={{width:200,height:200,backgroundColor:'blue',marginTop:20}} />
        </View>
        );
  }
}

我究竟做错了什么?

最佳答案

添加 flex: 1给您的 <View />成分。

<View style={{flex: 1, flexDirection:'column'}}>
  <Text>Show webview</Text>
  <WebView source={{html:"<html><body style='color:red'>Hello<br/>This is a test</body></html>"}} style={{width:200,height:200,backgroundColor:'blue',marginTop:20}} />
</View>

Here's a demo

关于react-native webview 没有出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47005587/

相关文章:

react-native - 当使用 Expo for React Native 时,有没有办法从文件中读取 mime 类型?

javascript - 如何将新获取的项目添加到 react native 的列表顶部?

Android 和 Jsoup

react-native - React Native 不建议使用 TextInput 发送电子邮件

javascript - react 堆栈导航

android - css 样式让 webview 显示空白,仅在 4.4(android kitkat)

android - 如果 webview 中的 url 相同,如何开始第三个 Activity

iphone - 如何禁用WebView的上下文菜单?

android - Ajax 不能在 android webview 中工作

javascript - 删除订阅