Gau*_*rma 1 typescript reactjs office-ui-fabric
我尝试了很多方法来在命令栏组件中渲染自定义组件,但没有成功。让我知道命令栏组件的可能性或局限性。
import { CommandBar } from 'office-ui-fabric-react/lib/CommandBar';
const items: ICommandBarItemProps[] = [{
key: "topicName",
text: displayTitle,
disabled: true,
buttonStyles: {
textContainer: {
color: colorBlack
},
label: {
fontWeight: "bold"
},
rootDisabled: {
backgroundColor: colorWhite
}
},
},
// in here i want to render custom component (just after topicName)
];
<CommandBar items = {items}
farItems = {farItems} />Run Code Online (Sandbox Code Playgroud)
我也尝试过这种方式,但出现错误。
{
key: 'custom',
onRender: (item: any) => <div>Custom</div>
}
每个项目都有CommandBar适合commandBarButtonAs您需要的属性。
文档:https ://developer.microsoft.com/en-us/fabric#/controls/web/commandbar#ICommandBarItemProps
一个例子:
<CommandBar items=[
{
key: 'button',
onClick: () => ({}),
commandBarButtonAs: () => (<Button />)
}
] />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3988 次 |
| 最近记录: |