出于某种原因,我的 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/