我试图在我的组件中使用react-自动完成。一切都在运转,好的结果显示出来了。但我无法对默认输入框进行样式设置。这是自动完成的
<Autocomplete
getItemValue={this.getItemValue}
items={this.state.autocompleteData}
renderItem={this.renderItem}
value={this.state.value}
onChange={this.onChange}
onSelect={this.onSelect}
menuStyle={menuStyle}
/>
下拉菜单的样式很好。
const menuStyle = {
borderRadius: '3px',
boxShadow: '0 2px 12px rgba(0, 0, 0, 0.1)',
background: 'rgba(255, 255, 255, 0.9)',
padding: '2px 0',
fontSize: '90%',
position: 'fixed',
overflow: 'auto',
maxHeight: '50%', // TODO: don't cheat, let it flow to the bottom
"zIndex": 100,
};
我试着按照这个问题的答案添加风格,但它不起作用。how to increase input text box size in react-autocomplete?
如何在输入框中添加样式?
发布于 2019-03-19 04:10:08
提供给支柱inputProps
的对象被用作输入的支持,因此您可以给一个带有包含menuStyles
的style
属性的对象。
<Autocomplete
getItemValue={this.getItemValue}
items={this.state.autocompleteData}
renderItem={this.renderItem}
value={this.state.value}
onChange={this.onChange}
onSelect={this.onSelect}
inputProps={{ style: menuStyle }}
/>
https://stackoverflow.com/questions/55240673
复制相似问题