Yuk*_*uki 4 javascript reactjs react-select
无论我做什么,我都无法更改选择的宽度。它总是保持不变,一些默认宽度(比如大约 75 像素)。
const Container = styled('div')`
width: 100%;
height: 100%;
display: flex;
flex-flow: row wrap;
justify-content: space-around;
`;
const selectStyles = {
valueContainer: base => ({
width: 300,
}),
group: base => ({
width: 300,
}),
container: base => ({
width: 300,
}),
control: base => ({
width: 300,
}),
singleValue: base => ({
width: 300,
}),
input: base => ({
width: 300,
color: theme.palette.text.primary,
'& input': {
font: 'inherit',
},
}),
}
return (
<SplitPane split='horizontal' defaultSize={260}>
<Paper
style={{ width: '100%' }}
>
<Container>
<Select
styles={selectStyles}
options={suggestions}
value={this.state.channel}
onChange={(value) => (this.setState({ channel: value }))}
/>
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
似乎您实际上是在寻找使 react-select 宽度在 flexbox 设计(例如 flex-growth)中正确运行的方法,在这种情况下,请参阅此回复,但简而言之,您可以使用以下样式:
const styles = {
container: base => ({
...base,
flex: 1
})
};
<Select styles={styles} />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4992 次 |
| 最近记录: |