reactjs - 如何从 React TextField Select 中删除箭头
问题描述
我正在使用 TextField Select 作为下拉菜单。尝试在选择时使用“components={{ DropdownIndicator:() => null}}”,但没有奏效。
<TextField disabled={true}
label="itemNo"
value={currentItem.itemNo}
variant="outlined"
InputLabelProps={{ style: { fontSize: 18, color: 'grey', backgroundColor: 'white', fontFamily: "monospace" }, shrink: true }}
select
>
{this.state.itemNo && this.state.itemNo.map((item) => (
<MenuItem style={{ fontSize: 14, fontFamily: "monospace" }} key={item.key} value={item.id}>
{item.key}
</MenuItem>
))}
</TextField>
解决方案
要删除选择下拉图标,您必须传入IconComponent: () => null
, SelectProps
Props 应用于 Select 元素。它接受选择元素道具的对象
有关select
's props的更多信息https://material-ui.com/api/select/
这是工作示例https://codesandbox.io/s/quizzical-frost-g4s52?file=/src/App.js
<TextField disabled={true}
label="itemNo"
value={currentItem.itemNo}
variant="outlined"
InputLabelProps={{ style: { fontSize: 18, color: 'grey', backgroundColor: 'white', fontFamily: "monospace" }, shrink: true }}
select
// for passing props in select component
SelectProps={{ IconComponent: () => null }}
>
{this.state.itemNo && this.state.itemNo.map((item) => (
<MenuItem style={{ fontSize: 14, fontFamily: "monospace" }} key={item.key} value={item.id}>
{item.key}
</MenuItem>
))}
</TextField>
推荐阅读
- sql - 使用 ID 列表将 SQL 表组合成 R 中的数据框
- image-processing - 使集群在 K-Means 中固定到位
- python - 如何在包含 while 循环的两个进程之间共享字符串?
- azure-iot-edge - 在 IoT Edge v1.1 上使用 Windows 容器从 ACR 中提取 edgeAgent 时出错
- twilio - Twilio 外出呼叫正在循环中触发
- typescript - TypeScript:字段默认值在执行超级构造函数时覆盖值集
- mysql - 如何仅在其他行的上下文中读取具有匹配条件的行
- reactjs - NPM---反应 / GANACHE
- javascript - 为什么我的 firstNode.nodeValue 返回 null?
- php - 在每一行和每一列中设置一个不能相互交叉的元素(想想国际象棋)