const list = [
{
id: 1,
text: "首页",
icon: <WapHomeOutlined />,
},
{
id: 2,
text: "分类",
icon: <AppsOutlined />,
},
{
id: 3,
text: "购物车",
num: 2,
icon: <ShoppingCartOutlined />,
},
{
id: 4,
text: "我的",
icon: <UserOutlined />,
},
]
const App = () => {
const [open, setOpen] = useState(false)
return <FixedNav open={open} onChange={setOpen} data={list} position={{ top: "150px" }} />
}
const list = [
{
id: 1,
text: "首页",
icon: <WapHomeOutlined />,
},
{
id: 2,
text: "分类",
icon: <AppsOutlined />,
},
{
id: 3,
text: "购物车",
num: 2,
icon: <ShoppingCartOutlined />,
},
{
id: 4,
text: "我的",
icon: <UserOutlined />,
},
]
const App = () => {
const [open, setOpen] = useState(false)
return (
<FixedNav
open={open2}
onChange={setOpen2}
data={list}
type="left"
backdrop={false}
position={{ top: "300px" }}
/>
)
}
const CustomerFixedNav = () => {
const [open, setOpen] = useState(false)
return (
<FixedNav
open={open}
onChange={setOpen}
type="left"
backdrop={false}
position={{ top: "400px" }}
content={
<>
<GiftOutlined color="#FFF" />
<span className="fixed-nav-text">{open ? "开" : "关"}</span>
</>
}
>
<ul className="taroify-fixed-nav_content customer">
<li className="taroify-fixed-nav_content_item">我</li>
<li className="taroify-fixed-nav_content_item">是</li>
<li className="taroify-fixed-nav_content_item">自</li>
<li className="taroify-fixed-nav_content_item">定</li>
<li className="taroify-fixed-nav_content_item">义</li>
</ul>
</FixedNav>
)
}
.fixed-nav-demo {
.fixed-nav-text {
color: #fff;
line-height: 26px;
width: 48px;
font-size: 24px;
}
.taroify-fixed-nav_content {
&.customer {
border-radius: 0 50px 50px 0;
margin: 0;
padding-left: 160px;
padding-right: 40px;
right: auto;
}
&_item {
align-items: center;
color: #1a1a1a;
display: flex;
flex: 1;
flex-direction: column;
flex-shrink: 0;
height: 100%;
justify-content: center;
min-width: 100px;
position: relative;
font-size: 28px;
}
}
}
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
open | 是否打开 | boolean | false |
data | 悬浮导航内数据 | FixedNavItem[] | [] |
backdrop | 是否显示遮罩层 | boolean | true |
activeText | 收起按钮文案 | string | 收起导航 |
inactiveText | 展开按钮文案 | string | 快速导航 |
type | 悬浮导航方向 | left | right | right |
position | 悬浮导航垂直位置 | FixedNavPosition | {top: 'auto', bottom: 'auto'} |
content | 自定义按钮 | ReactNode | - |
组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 ConfigProvider 组件。
名称 | 默认值 | 描述 |
---|---|---|
—fixed-nav-z-index | 1010 | - |
—fixed-nav-z-content-index | 1009 | - |
—fixed-nav-button-background | var(—blue, $blue) | - |
—fixed-nav-button-font-size | 12px * $hd | - |
—fixed-nav-background-color | var(—white, $white) | - |
—fixed-nav-color | var(—gray-8, $gray-8) | - |