如何在本机反应中隐藏 TextInput 上的滚动条指示器

IKK*_*KKA 7 reactjs react-native expo

我想隐藏或删除 TextInput 组件上的滚动条指示器。我将多行道具启用为true然后将道具rollEnabled设置为false。但在我的组件中仍然显示滚动指示器。我正在使用以下代码。请帮助我如何解决这个问题。

<TextInput
        multiline={true}
        scrollEnabled={false}
        style={{
          backgroundColor: 'green',
          height:50,
          fontSize: 20,
          color: '#ffff',
          fontFamily: 'medium'
        }}
      />
Run Code Online (Sandbox Code Playgroud)

Rok*_*kas 0

截至 2023 年底, React Native 中不存在不显示scroll indicatorin组件的属性。TextInput

在这种情况下,我提出的解决方案非常简单,但需要ScrollView组件和一些额外的样式。

<View style={{ flex: 1, borderWidth: 1, borderColor: 'transparent' }}>
  <ScrollView
    style={{
     flex: 1,
     borderWidth: 1,
     borderColor: 'transparent',
     paddingHorizontal: 5,
     borderRadius: 8,
    }}
   showsVerticalScrollIndicator={false} // Hide the scroll indicator
  >
  <TextInput
   value={content}
   onChangeText={setContent}
   multiline
   numberOfLines={50}
   style={{
     flex: 1,
     fontSize: 14,
   }}
  />
 </ScrollView>
</View>
Run Code Online (Sandbox Code Playgroud)

希望这能回答您的问题,并帮助遇到此问题的每个人。