让我在序言中说我是本机反应新手
这是我的组成部分:
/**
* 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"
似乎没有太大帮助。
答案 0 :(得分:1)
从样式中删除弹性
<View style={{ flexDirection: "row", marginRight: 0, backgroundColor: 'red', alignSelf:'baseline', flexWrap: "wrap"}}>