mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-30 02:48:55 +08:00
feat: nav 的连接支持设置 target (#2177)
This commit is contained in:
parent
54efd883e1
commit
63466f47d2
@ -31,6 +31,11 @@ order: 58
|
||||
{
|
||||
"label": "Nav 3",
|
||||
"to": "/docs/renderers"
|
||||
},
|
||||
{
|
||||
"label": "外部地址",
|
||||
"to": "http://www.baidu.com/",
|
||||
"target": "_blank"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -115,20 +120,21 @@ order: 58
|
||||
|
||||
## 属性表
|
||||
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ----------------- | ---------------------------------------- | ------- | ---------------------------------------------------------------- |
|
||||
| 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 接口。 |
|
||||
| links | `Array` | | 链接集合 |
|
||||
| links[x].label | `string` | | 名称 |
|
||||
| links[x].to | [模板](../../docs/concepts/template) | | 链接地址 |
|
||||
| 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) | | 可以不配置,如果配置优先级更高 |
|
||||
| 属性名 | 类型 | 默认值 | 说明 |
|
||||
| ----------------- | ---------------------------------------- | -------- | ---------------------------------------------------------------- |
|
||||
| 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 接口。 |
|
||||
| links | `Array` | | 链接集合 |
|
||||
| links[x].label | `string` | | 名称 |
|
||||
| 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) | | 可以不配置,如果配置优先级更高 |
|
||||
|
@ -131,6 +131,11 @@ export default class PlayGround extends React.Component {
|
||||
return;
|
||||
}
|
||||
|
||||
if (action && to && action.target) {
|
||||
window.open(to, action.target);
|
||||
return;
|
||||
}
|
||||
|
||||
if (/^https?:\/\//.test(to)) {
|
||||
window.location.replace(to);
|
||||
} else {
|
||||
|
@ -62,6 +62,10 @@ export default function (schema, showCode, envOverrides) {
|
||||
: window.open(to);
|
||||
return;
|
||||
}
|
||||
if (action && to && action.target) {
|
||||
window.open(to, action.target);
|
||||
return;
|
||||
}
|
||||
if (/^https?:\/\//.test(to)) {
|
||||
window.location.replace(to);
|
||||
} else {
|
||||
|
@ -226,6 +226,12 @@ export function embed(
|
||||
return;
|
||||
}
|
||||
|
||||
// 主要是支持 nav 中的跳转
|
||||
if (action && to && action.target) {
|
||||
window.open(to, action.target);
|
||||
return;
|
||||
}
|
||||
|
||||
if (/^https?:\/\//.test(to)) {
|
||||
window.location.replace(to);
|
||||
} else {
|
||||
|
@ -36,6 +36,8 @@ export type NavItemSchema = {
|
||||
|
||||
to?: SchemaUrlPath;
|
||||
|
||||
target?: string;
|
||||
|
||||
unfolded?: boolean;
|
||||
active?: boolean;
|
||||
|
||||
@ -85,6 +87,7 @@ export interface Link {
|
||||
className?: string;
|
||||
label?: string;
|
||||
to?: string;
|
||||
target?: string;
|
||||
icon?: string;
|
||||
active?: boolean;
|
||||
activeOn?: string;
|
||||
|
Loading…
Reference in New Issue
Block a user