您应该更改您的结构以使它们适应 Fluent 设计。Nav
组件是您正在寻找的。这是如何使用 Fluent Design + Gatsby 构建导航窗格的示例:
import React from 'react';
import { Nav, initializeIcons } from '@fluentui/react';
const navigationStyles = {
root: {
height: '100vh',
boxSizing: 'border-box',
border: '1px solid #eee',
overflowY: 'auto',
paddingTop: '10vh',
},
};
const links = [
{
links: [
{
name: 'Home',
key:'key1',
url: '/',
iconProps: {
iconName: 'News',
styles: {
root: {
fontSize: 20,
color: '#106ebe',
},
}
}
},
{
name: 'Contact',
key: 'key2',
url: '/contact',
iconProps: {
iconName: 'PlayerSettings',
styles: {
root: {
fontSize: 20,
color: '#106ebe',
},
}
}
},
],
},
];
const Navigation = () => {
return (
<Nav
groups={links}
selectedKey='key1'
styles={navigationStyles}
/>
);
};
export default Navigation;
Nav
组件接受一组链接,并使用对和属性prop
自动处理它。name
url