reactjs - React JS Fluent ui onRenderTitle
问题描述
您好,我是 react 新手,必须使用流利的 ui
我正在尝试更改自定义选项标签
onRenderTitle={(选项) => ${options.name} (${options.roll_number})
}
我的代码:
<Dropdown
placeholder={"Select your School"}
onChange={(event, val) => {
if (val === null) {
setSelectedSchool("")
} else {
setSelectedSchool(val.key);
}
}}
value={selectedcounty}
options={getschool.filter(x => x.county === selectedcounty).map((school, key) => (
{
key: school.name, text: school.name
}
))}
onRenderTitle={(options) => `${options.name} (${options.roll_number})`}
/>
解决方案
onRenderTitle
是一个返回Element
not的函数String
。选项类型是IDropdownOption[]
<Dropdown
...
onRenderTitle={options => <span>{options[0].key} ({options[0].text})</span>}
/>
推荐阅读
- ios - AudioKit shouldOptimizeForRealtimePlot 导致绘图变为空白
- mysql - 从同一个表中重叠的唯一天数列表
- vb.net - VB.Net 使用属性名称(字符串)编辑对象属性
- graphql - 我们可以使用 Graph-ql java 客户端来查询休息吗
- c# - 如何使用带有动态字符串的实体框架 where 子句
- angular - 主题更改后更新标题上的值
- javascript - GraphQL:为构建模式提供的一种类型缺少名称
- java - 寻求帮助创建类似于 bluej 中自动大写的代码 [有一个答案,但需要进一步澄清]
- flutter - 检测 IgnorePointer 或 AbsorbPointer 内的某些小部件上的指针事件
- visual-studio-code - 如何在 VS Code 中执行包含括号 {} 的搜索