我一直试图给出<TextInput>一个letterSpacing风格,但它似乎只适用于<Text>.React Native中有没有办法增加TextInput中字符之间的空间?
这增加了角色之间的空间
<Text style={{'letterSpacing': 5}}>Some Text</Text>
Run Code Online (Sandbox Code Playgroud)
这不行
<TextInput style={{'letterSpacing': 5}} />
Run Code Online (Sandbox Code Playgroud)
这是一个可能的解决方案,也许不是更好。
class Form extends React.Component {
constructor() {
super();
this.state = {
value: '',
};
this.onChangeText = this.onChangeText.bind(this);
}
onChangeText(e) {
const val = e.target.value.replace(/ /g, '').split('');
const spaced = val.join(' ');
this.setState({
value: spaced,
});
}
render() {
return(
<div style={{flexDirection: 'column'}}>
<div>Type Text</div>
<input
type='text'
onChange={this.onChangeText}
value={this.state.value}
/>
</div>
);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3549 次 |
| 最近记录: |