Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
京东前端
nutui-react
提交
ea5011da
N
nutui-react
项目概览
京东前端
/
nutui-react
通知
0
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
nutui-react
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
ea5011da
编写于
7月 18, 2022
作者:
Y
yangxiaolu1993
提交者:
GitHub
7月 18, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: popover 添加在线编辑 (#159)
Co-authored-by:
N
yangxiaolu3
<
yangxiaolu3@jd.com
>
上级
8dfdff8d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
119 addition
and
82 deletion
+119
-82
src/packages/popover/doc.md
src/packages/popover/doc.md
+119
-82
未找到文件。
src/packages/popover/doc.md
浏览文件 @
ea5011da
...
...
@@ -15,56 +15,54 @@ import { Popover } from '@nutui/nutui-react';
### 基本用法
Popover 支持明朗和暗黑两种风格,默认为明朗风格,将 theme 属性设置为 dark 可切换为暗黑风格。
:::demo
```
tsx
<
Popover
visible
=
{
lightTheme
}
onClick
=
{
()
=>
{
lightTheme
?
setLightTheme
(
false
)
:
setLightTheme
(
true
)}
}
list
=
{
itemList
}
>
<
Button
type
=
"primary"
shape
=
"square"
>
明朗风格
</
Button
>
</
Popover
>
<
Popover
visible
=
{
darkTheme
}
theme
=
"dark"
onClick
=
{
()
=>
{
darkTheme
?
setDarkTheme
(
false
)
:
setDarkTheme
(
true
)}
}
list
=
{
itemList
}
>
<
Button
type
=
"primary"
shape
=
"square"
>
暗黑风格
</
Button
>
</
Popover
>
```
```
javascript
import
React
,
{
useState
,
useRef
}
from
"
react
"
;
import
{
Popover
,
Button
,
Icon
}
from
'
@nutui/nutui-react
'
;
const
App
=
()
=>
{
const
[
lightTheme
,
setLightTheme
]
=
useState
(
false
)
const
[
darkTheme
,
setDarkTheme
]
=
useState
(
false
)
const
itemList
=
[
{
name
:
'
选项一
'
},
{
name
:
'
选项二
'
},
{
name
:
'
选项三
'
}];
{
name
:
'
选项三
'
},
]
return
(
<>
<
Popover
visible
=
{
lightTheme
}
onClick
=
{
()
=>
{
lightTheme
?
setLightTheme
(
false
)
:
setLightTheme
(
true
)}
}
list
=
{
itemList
}
>
<
Button
type
=
"primary"
shape
=
"square"
>
明朗风格
</
Button
>
</
Popover
>
<
Popover
visible
=
{
darkTheme
}
theme
=
"dark"
onClick
=
{
()
=>
{
darkTheme
?
setDarkTheme
(
false
)
:
setDarkTheme
(
true
)}
}
list
=
{
itemList
}
>
<
Button
type
=
"primary"
shape
=
"square"
>
暗黑风格
</
Button
>
</
Popover
>
</>
)
};
export
default
App
;
```
:::
### 选项配置
:::demo
```
tsx
<
Popover
visible
=
{
showIcon
}
theme
=
"dark"
onClick
=
{
()
=>
{
showIcon
?
setShowIcon
(
false
)
:
setShowIcon
(
true
)}
}
list
=
{
iconItemList
}
>
<
Button
type
=
"primary"
shape
=
"square"
>
展示图标
</
Button
>
</
Popover
>
<
Popover
visible
=
{
disableAction
}
onClick
=
{
()
=>
{
disableAction
?
setDisableAction
(
false
)
:
setDisableAction
(
true
)}
}
list
=
{
itemListDisabled
}
>
<
Button
type
=
"primary"
shape
=
"square"
>
禁用选项
</
Button
>
</
Popover
>
```
```
javascript
import
React
,
{
useState
,
useRef
}
from
"
react
"
;
import
{
Popover
,
Button
,
Icon
}
from
'
@nutui/nutui-react
'
;
const
App
=
()
=>
{
const
[
showIcon
,
setShowIcon
]
=
useState
(
false
)
const
[
disableAction
,
setDisableAction
]
=
useState
(
false
)
const
iconItemList
=
[
const
iconItemList
=
[
{
name
:
'
选项一
'
,
icon
:
'
my2
'
},
{
name
:
'
选项二
'
,
icon
:
'
cart2
'
},
{
name
:
'
选项三
'
,
icon
:
'
location2
'
}
...
...
@@ -75,32 +73,37 @@ Popover 支持明朗和暗黑两种风格,默认为明朗风格,将 theme
{
name
:
'
选项三
'
}
];
return
(
<>
<
Popover
visible
=
{
showIcon
}
theme
=
"dark"
onClick
=
{
()
=>
{
showIcon
?
setShowIcon
(
false
)
:
setShowIcon
(
true
)}
}
list
=
{
iconItemList
}
>
<
Button
type
=
"primary"
shape
=
"square"
>
展示图标
</
Button
>
</
Popover
>
<
Popover
visible
=
{
disableAction
}
onClick
=
{
()
=>
{
disableAction
?
setDisableAction
(
false
)
:
setDisableAction
(
true
)}
}
list
=
{
itemListDisabled
}
>
<
Button
type
=
"primary"
shape
=
"square"
>
禁用选项
</
Button
>
</
Popover
>
</>
);
};
export
default
App
;
```
:::
### 自定义内容
:::demo
```
tsx
<
Popover
visible
=
{
customized
}
onClick
=
{
()
=>
{
customized
?
setCustomized
(
false
)
:
setCustomized
(
true
)}
}
>
<
Button
type
=
"primary"
shape
=
"square"
>
自定义内容
</
Button
>
{
customized
?
<
div
className
=
"self-content"
style
=
{
selfContentStyle
}
>
{
selfContent
.
map
((
item
:
any
)
=>
{
return
<
div
className
=
"self-content-item"
style
=
{
selfContentItem
}
key
=
{
item
.
name
}
>
<
Icon
name
=
{
item
.
name
}
size
=
"15"
/>
<
div
className
=
"self-content-desc"
style
=
{
selfContentDesc
}
>
{
item
.
desc
}
</
div
>
</
div
>
})
}
</
div
>
:
''
}
</
Popover
>
```
```
javascript
import
React
,
{
useState
,
useRef
}
from
"
react
"
;
import
{
Popover
,
Button
}
from
'
@nutui/nutui-react
'
;
const
App
=
()
=>
{
const
[
customized
,
setCustomized
]
=
useState
(
false
)
const
selfContent
=
[
{
...
...
@@ -129,39 +132,41 @@ Popover 支持明朗和暗黑两种风格,默认为明朗风格,将 theme
}
];
return
(
<>
<
Popover
visible
=
{
customized
}
onClick
=
{
()
=>
{
customized
?
setCustomized
(
false
)
:
setCustomized
(
true
)}
}
>
<
Button
type
=
"primary"
shape
=
"square"
>
自定义内容
</
Button
>
{
customized
?
<
div
className
=
"self-content"
style
=
{
selfContentStyle
}
>
{
selfContent
.
map
((
item
:
any
)
=>
{
return
<
div
className
=
"self-content-item"
style
=
{
selfContentItem
}
key
=
{
item
.
name
}
>
<
Icon
name
=
{
item
.
name
}
size
=
"15"
/>
<
div
className
=
"self-content-desc"
style
=
{
selfContentDesc
}
>
{
item
.
desc
}
</
div
>
</
div
>
})
}
</
div
>
:
''
}
</
Popover
>
</>
)
}
export
default
App
;
```
:::
### 位置自定义
:::demo
```
tsx
<
Popover
visible
=
{
topLocation
}
location
=
"top"
theme
=
"dark"
onClick
=
{
()
=>
{
topLocation
?
setTopLocation
(
false
)
:
setTopLocation
(
true
)}
}
list
=
{
iconItemList
}
>
<
Button
type
=
"primary"
shape
=
"square"
>
向上弹出
</
Button
>
</
Popover
>
<
Popover
visible
=
{
rightLocation
}
location
=
"right"
theme
=
"dark"
onClick
=
{
()
=>
{
rightLocation
?
setRightLocation
(
false
)
:
setRightLocation
(
true
)}
}
list
=
{
iconItemList
}
>
<
Button
type
=
"primary"
shape
=
"square"
>
向右弹出
</
Button
>
</
Popover
>
<
Popover
visible
=
{
leftLocation
}
location
=
"left"
theme
=
"dark"
onClick
=
{
()
=>
{
leftLocation
?
setLeftLocation
(
false
)
:
setLeftLocation
(
true
)}
}
list
=
{
iconItemList
}
>
<
Button
type
=
"primary"
shape
=
"square"
>
向左弹出
</
Button
>
</
Popover
>
```
```
javascript
import
React
,
{
useState
,
useRef
}
from
"
react
"
;
import
{
Popover
,
Button
}
from
'
@nutui/nutui-react
'
;
const
App
=
()
=>
{
const
[
topLocation
,
setTopLocation
]
=
useState
(
false
)
const
[
rightLocation
,
setRightLocation
]
=
useState
(
false
)
const
[
leftLocation
,
setLeftLocation
]
=
useState
(
false
)
...
...
@@ -171,7 +176,39 @@ Popover 支持明朗和暗黑两种风格,默认为明朗风格,将 theme
{
name
:
'
选项三
'
,
icon
:
'
location2
'
}
];
return
(
<>
<
Popover
visible
=
{
topLocation
}
location
=
"top"
theme
=
"dark"
onClick
=
{
()
=>
{
topLocation
?
setTopLocation
(
false
)
:
setTopLocation
(
true
)}
}
list
=
{
iconItemList
}
>
<
Button
type
=
"primary"
shape
=
"square"
>
向上弹出
</
Button
>
</
Popover
>
<
Popover
visible
=
{
rightLocation
}
location
=
"right"
theme
=
"dark"
onClick
=
{
()
=>
{
rightLocation
?
setRightLocation
(
false
)
:
setRightLocation
(
true
)}
}
list
=
{
iconItemList
}
>
<
Button
type
=
"primary"
shape
=
"square"
>
向右弹出
</
Button
>
</
Popover
>
<
Popover
visible
=
{
leftLocation
}
location
=
"left"
theme
=
"dark"
onClick
=
{
()
=>
{
leftLocation
?
setLeftLocation
(
false
)
:
setLeftLocation
(
true
)}
}
list
=
{
iconItemList
}
>
<
Button
type
=
"primary"
shape
=
"square"
>
向左弹出
</
Button
>
</
Popover
>
</>
)
}
export
default
App
;
```
:::
## API
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录