让我先说一句,我对react-native是个新手
下面是我的组件:
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React, { Component } from 'react';
import { Text, View, Image, TextInput } from 'react-native';
class CountryCodeInput extends Component {
state = { text: '' }
constructor(props) {
super(props)
}
componentDidMount() {
}
onTextChange(text) {
if (/^\d+$/.test(text) || text === "") {
this.setState({ text })
}
// this.props.onTextChange(text)
}
render() {
return (
<View style={{flex: 1, flexDirection: "row", marginRight: 0, backgroundColor: 'red', alignSelf:'baseline', flexWrap: "wrap"}}>
<Text style={{backgroundColor:"yellow"}}>+</Text>
<TextInput
onChangeText={(text)=>this.onTextChange(text)}
maxLength={3}
keyboardType="numeric"
style={{backgroundColor:"grey", borderBottomColor: 'black', borderBottomWidth: 1, fontSize: 16, height: 24, width: 36, paddingVertical: 4 }}
value={this.state.text} />
</View>
);
}
}
export default CountryCodeInput
下面是它看起来的样子:
我需要移除所有的红色部分,并将黄色部分的高度限制为灰色部分的高度。我该怎么做呢?
alignSelf:'baseline'
和flexWrap: "wrap"
似乎没有多大帮助。
发布于 2019-06-10 01:33:58
将flex从你的风格中移除
<View style={{ flexDirection: "row", marginRight: 0, backgroundColor: 'red', alignSelf:'baseline', flexWrap: "wrap"}}>
https://stackoverflow.com/questions/56516744
复制相似问题