如何在 React Native 中绘制虚线边框样式

Abh*_*rav 17 javascript css reactjs react-native

我正在使用以下样式,我正在尝试绘制虚线边框样式,但它始终是实心的。请建议。

<View style={{paddingLeft:10,
 height:300, marginBottom:10, 
 borderWidth:1,
 borderStyle: 'dashed',
 borderColor:'red',
 borderTopColor:'white'}}>
Run Code Online (Sandbox Code Playgroud)

// 谢谢

Emi*_*mil 29

您需要添加borderRadius: 1才能使其工作。

  • 注意:在撰写本文时,在 React Native 0.63.2 中将“borderStyle”应用于单个边框边缘已被破坏,但有一个开放的 PR 可以修复此限制:https://github.com/facebook/react-native/pull/ 29099 (2认同)

Sum*_*tel 6

尝试遵循它应该有效

borderStyle: 'dotted',
borderRadius: 1,
Run Code Online (Sandbox Code Playgroud)

  • 注意:在撰写本文时,在 React Native 0.63.2 中将“borderStyle”应用于单个边框边缘已被破坏,但有一个开放的 PR 可以修复此限制:https://github.com/facebook/react-native/pull/ 29099 (2认同)

小智 6

根据github问题评论(https://github.com/facebook/react-native/issues/24224):

<View style={[{ height: 1, overflow: 'hidden' }]}>
  <View style={[{ height: 2, borderWidth: 1, borderColor: '#ddd', borderStyle: 'dashed' }]}></View>
</View>
Run Code Online (Sandbox Code Playgroud)