2020-07-28 10:03:53 +08:00
|
|
|
|
---
|
|
|
|
|
title: Nav 导航
|
2020-07-29 16:20:21 +08:00
|
|
|
|
description:
|
2020-07-28 10:03:53 +08:00
|
|
|
|
type: 0
|
|
|
|
|
group: ⚙ 组件
|
|
|
|
|
menuName: Nav
|
2020-07-29 16:20:21 +08:00
|
|
|
|
icon:
|
2020-07-28 10:03:53 +08:00
|
|
|
|
order: 58
|
|
|
|
|
---
|
2020-07-29 16:20:21 +08:00
|
|
|
|
|
2020-07-28 10:03:53 +08:00
|
|
|
|
用于展示链接导航
|
|
|
|
|
|
|
|
|
|
## 基本用法
|
|
|
|
|
|
2021-01-07 23:35:03 +08:00
|
|
|
|
```schema: scope="body"
|
2020-07-28 10:03:53 +08:00
|
|
|
|
{
|
|
|
|
|
"type": "nav",
|
|
|
|
|
"stacked": true,
|
|
|
|
|
"className": "w-md",
|
2021-11-05 11:57:28 +08:00
|
|
|
|
"itemBadge": {
|
|
|
|
|
"mode": "ribbon",
|
|
|
|
|
"text": "${customText}",
|
|
|
|
|
"position": "top-left",
|
|
|
|
|
"visibleOn": "this.customText",
|
|
|
|
|
"level": "${customLevel}"
|
|
|
|
|
},
|
2020-07-28 10:03:53 +08:00
|
|
|
|
"links": [
|
|
|
|
|
{
|
|
|
|
|
"label": "Nav 1",
|
|
|
|
|
"to": "/docs/index",
|
2021-01-28 17:04:31 +08:00
|
|
|
|
"icon": "https://suda.cdn.bcebos.com/images%2F2021-01%2Fdiamond.svg",
|
2020-07-28 10:03:53 +08:00
|
|
|
|
"active": true
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "Nav 2",
|
2021-11-01 10:14:25 +08:00
|
|
|
|
"to": "/docs/api",
|
2021-11-05 11:57:28 +08:00
|
|
|
|
"customText": "HOT",
|
|
|
|
|
"customLevel": "danger"
|
2020-07-28 10:03:53 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "Nav 3",
|
2021-11-05 11:57:28 +08:00
|
|
|
|
"to": "/docs/renderers",
|
|
|
|
|
"customText": "SUC",
|
|
|
|
|
"customLevel": "success"
|
2021-07-01 00:45:13 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "外部地址",
|
|
|
|
|
"to": "http://www.baidu.com/",
|
|
|
|
|
"target": "_blank"
|
2020-07-28 10:03:53 +08:00
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2020-12-30 20:15:06 +08:00
|
|
|
|
## 配置多层级
|
|
|
|
|
|
2021-01-07 23:35:03 +08:00
|
|
|
|
```schema: scope="body"
|
2020-12-30 20:15:06 +08:00
|
|
|
|
{
|
|
|
|
|
"type": "nav",
|
|
|
|
|
"stacked": true,
|
|
|
|
|
"className": "w-md",
|
|
|
|
|
"links": [
|
|
|
|
|
{
|
|
|
|
|
"label": "Nav 1",
|
|
|
|
|
"to": "/docs/index",
|
|
|
|
|
"icon": "fa fa-user",
|
|
|
|
|
"active": true
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "Nav 2",
|
|
|
|
|
"unfolded": true,
|
|
|
|
|
"children": [
|
|
|
|
|
{
|
|
|
|
|
"label": "Nav 2-1",
|
|
|
|
|
"children": [
|
|
|
|
|
{
|
|
|
|
|
"label": "Nav 2-1-1",
|
|
|
|
|
"to": "/docs/api-2-1-1"
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "Nav 2-2",
|
|
|
|
|
"to": "/docs/api-2-2"
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "Nav 3",
|
|
|
|
|
"to": "/docs/renderers"
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2020-07-28 10:03:53 +08:00
|
|
|
|
## 横向摆放
|
|
|
|
|
|
2021-01-07 23:35:03 +08:00
|
|
|
|
```schema: scope="body"
|
2020-07-28 10:03:53 +08:00
|
|
|
|
{
|
|
|
|
|
"type": "nav",
|
|
|
|
|
"stacked": false,
|
|
|
|
|
"links": [
|
|
|
|
|
{
|
|
|
|
|
"label": "Nav 1",
|
|
|
|
|
"to": "/docs/index",
|
|
|
|
|
"icon": "fa fa-user"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "Nav 2",
|
|
|
|
|
"to": "/docs/api"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "Nav 3",
|
|
|
|
|
"to": "/docs/renderers"
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2021-09-29 20:00:56 +08:00
|
|
|
|
## 动态导航
|
|
|
|
|
|
|
|
|
|
通过配置 source 来实现动态生成导航,source 可以是 api 地址或者变量,比如
|
|
|
|
|
|
|
|
|
|
```schema
|
|
|
|
|
{
|
|
|
|
|
"type": "page",
|
|
|
|
|
"data": {
|
|
|
|
|
"nav": [
|
|
|
|
|
{
|
|
|
|
|
"label": "Nav 1",
|
|
|
|
|
"to": "/docs/index",
|
|
|
|
|
"icon": "fa fa-user"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "Nav 2",
|
|
|
|
|
"to": "/docs/api"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "Nav 3",
|
|
|
|
|
"to": "/docs/renderers"
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
"body": {
|
|
|
|
|
"type": "nav",
|
|
|
|
|
"stacked": true,
|
|
|
|
|
"source": "${nav}"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2021-04-21 00:22:18 +08:00
|
|
|
|
## 懒加载
|
|
|
|
|
|
|
|
|
|
可以一次只加载部分层级,更深层次的选项可以标记为 `defer` 为 true,这样只有点开的时才会加载。
|
|
|
|
|
|
|
|
|
|
```schema: scope="body"
|
|
|
|
|
{
|
|
|
|
|
"type": "nav",
|
|
|
|
|
"stacked": true,
|
2021-08-09 18:05:01 +08:00
|
|
|
|
"source": "/api/options/nav?parentId=${value}"
|
2021-04-21 00:22:18 +08:00
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2021-11-01 10:14:25 +08:00
|
|
|
|
## 更多操作
|
|
|
|
|
|
|
|
|
|
```schema: scope="body"
|
|
|
|
|
{
|
|
|
|
|
"type": "nav",
|
|
|
|
|
"stacked": true,
|
|
|
|
|
"className": "w-md",
|
|
|
|
|
"draggable": true,
|
|
|
|
|
"saveOrderApi": "/api/options/nav",
|
|
|
|
|
"source": "/api/options/nav?parentId=${value}",
|
|
|
|
|
"itemActions": [
|
|
|
|
|
{
|
|
|
|
|
"type": "icon",
|
|
|
|
|
"icon": "cloud",
|
|
|
|
|
"visibleOn": "this.to === '?cat=1'"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"type": "dropdown-button",
|
|
|
|
|
"level": "link",
|
|
|
|
|
"icon": "fa fa-ellipsis-h",
|
|
|
|
|
"hideCaret": true,
|
|
|
|
|
"buttons": [
|
|
|
|
|
{
|
|
|
|
|
"type": "button",
|
|
|
|
|
"label": "编辑",
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"type": "button",
|
|
|
|
|
"label": "删除"
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2020-07-28 10:03:53 +08:00
|
|
|
|
## 属性表
|
|
|
|
|
|
2021-07-01 00:45:13 +08:00
|
|
|
|
| 属性名 | 类型 | 默认值 | 说明 |
|
|
|
|
|
| ----------------- | ---------------------------------------- | -------- | ---------------------------------------------------------------- |
|
|
|
|
|
| type | `string` | `"nav"` | 指定为 Nav 渲染器 |
|
|
|
|
|
| className | `string` | | 外层 Dom 的类名 |
|
|
|
|
|
| stacked | `boolean` | `true` | 设置成 false 可以以 tabs 的形式展示 |
|
|
|
|
|
| source | `string` 或 [API](../../docs/types/api) | | 可以通过变量或 API 接口动态创建导航 |
|
|
|
|
|
| deferApi | [API](../../docs/types/api) | | 用来延时加载选项详情的接口,可以不配置,不配置公用 source 接口。 |
|
2021-11-01 10:14:25 +08:00
|
|
|
|
| itemActions | [SchemaNode](../../docs/types/schemanode) | | 更多操作相关配置 |
|
|
|
|
|
| draggable | `boolean` | | 是否支持拖拽排序 |
|
2021-11-05 11:57:28 +08:00
|
|
|
|
| dragOnSameLevel | `boolean` | | 仅允许同层级内拖拽 |
|
2021-11-01 10:14:25 +08:00
|
|
|
|
| saveOrderApi | `string` 或 [API](../../docs/types/api) | |保存排序的 api |
|
2021-11-05 11:57:28 +08:00
|
|
|
|
| itemBadge | [BadgeSchema](../../components/badge) | | 角标 |
|
2021-07-01 00:45:13 +08:00
|
|
|
|
| links | `Array` | | 链接集合 |
|
2021-11-01 10:14:25 +08:00
|
|
|
|
| links[x].label | `string` | | 名称 |
|
2021-07-01 00:45:13 +08:00
|
|
|
|
| links[x].to | [模板](../../docs/concepts/template) | | 链接地址 |
|
|
|
|
|
| links[x].target | `string` | 链接关系 | |
|
|
|
|
|
| links[x].icon | `string` | | 图标 |
|
|
|
|
|
| links[x].children | `Array<link>` | | 子链接 |
|
|
|
|
|
| links[x].unfolded | `boolean` | | 初始是否展开 |
|
|
|
|
|
| links[x].active | `boolean` | | 是否高亮 |
|
|
|
|
|
| links[x].activeOn | [表达式](../../docs/concepts/expression) | | 是否高亮的条件,留空将自动分析链接地址 |
|
|
|
|
|
| links[x].defer | `boolean` | | 标记是否为懒加载项 |
|
|
|
|
|
| links[x].deferApi | [API](../../docs/types/api) | | 可以不配置,如果配置优先级更高 |
|