如何将文本输入光标的初始位置设置为左上角

How do I set the initial position of the textinput cursor to the top-left corner

我有一个 TextInput,出于某种原因,它的初始起点位于中间,如图所示:

我怀疑 textinput 认为第一行从那里开始,但我很想知道如何以其他方式告诉它

我希望它从左上角开始。

代码如下所示:

<View style={styles.desc}>
     <Text style={styles.text}>Beskrivelse:</Text>
     <TextInput style={styles.desctextinput}
                multiline={true}
                onChangeText={(newText) => {
                     let obj = this.state.data;
                     obj.description = newText;
                     this.setState({data: obj});
                }}
                onBlur={() => {
                     console.log(this.state.data.description)
                }}
                />
</View>
const styles = StyleSheet.create({
    text: {
        fontSize: 16,
        fontWeight: 'bold'
    },
    desc: {
        flexDirection: 'column',
        paddingVertical: 10,
        paddingHorizontal: 15,
        height: 300
    },
    desctextinput: {
        flex: 1,
        borderWidth: 1,
        paddingTop: 5,
        paddingLeft: 5,
        borderColor: '#f7f7f7'
    }

});

您可以通过添加以下内容轻松解决此问题:

textAlignVertical: 'top'

到您的 desctextinput 样式。