53 lines
2.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# RMoreDropdown
<script setup>
import MoreDropdownDemo from '../../examples/MoreDropdownDemo.vue'
</script>
包装 `NDropdown`,为行操作提供默认的更多图标。`options`、`trigger`、`placement`、`onSelect(key, option)`、受控显隐等沿用 Naive UI Dropdown。
## 交互示例
<ClientOnly>
<MoreDropdownDemo />
</ClientOnly>
::: details 查看示例源码
<<< @/examples/MoreDropdownDemo.vue
:::
| 属性 | 默认 | 说明 |
| -------------- | ------------------------------- | ------------------------------------- |
| `icon` | `'action/more'` | 类型为 `IconName`,使用完整分包路径。 |
| `iconSize` | 跟随 RIcon | 触发图标大小,省略时为 20 px。 |
| `cursor` | `'inherit'` | 默认继承所在控件的指针样式。 |
| `triggerLabel` | 跟随注入翻译或 `'More actions'` | 默认图标按钮的可访问名称。 |
默认触发器是可键盘聚焦的图标按钮。`placement` 默认 `'bottom-start'`,可由调用方覆盖。`default` 插槽替换整个触发器,自定义触发器应使用具有可访问名称的原生按钮或 `NButton`。列表行中根据业务需要阻止点击冒泡,避免同时触发行导航。
```tsx
import { RIcon, RMoreDropdown } from '@/components'
import { NButton } from 'naive-ui'
export const renderRowActions = (edit: () => void) => (
<RMoreDropdown
trigger="click"
placement="bottom-end"
options={[{ key: 'edit', label: '编辑' }]}
onSelect={(key) => {
if (key === 'edit') edit()
}}
>
<NButton
text
aria-label="更多操作"
onClick={(event) => event.stopPropagation()}
>
<RIcon name="action/more" />
</NButton>
</RMoreDropdown>
)
```
[组件实现](https://github.com/XiaoDaiGua-Ray/ray-template/blob/main/packages/ui/src/RMoreDropdown/src/MoreDropdown.tsx) · [Props](https://github.com/XiaoDaiGua-Ray/ray-template/blob/main/packages/ui/src/RMoreDropdown/src/props.ts)