38 lines
1.0 KiB
Markdown
38 lines
1.0 KiB
Markdown
# UserProfilePopup 用户资料弹窗
|
||
|
||
用户资料卡弹窗,把 `UserProfile` 挂载到 `timi-web` 的弹层容器中,由悬停触发显示。
|
||
|
||
## 基础用法
|
||
|
||
:::preview 基础用法 || 把鼠标移到文字上查看,切换按钮可更换展示的用户
|
||
|
||
demo-preview=../demos/user-profile-popup/basic.vue
|
||
|
||
:::
|
||
|
||
## 何时使用
|
||
|
||
页面上出现用户名、头像等标识,且希望悬停时展示完整资料时使用。
|
||
|
||
## 工作原理
|
||
|
||
组件本身是一个隐藏容器,挂载后把自己注册到 `popupUserStore.config`,弹层类型为 `PopupType.EL`:
|
||
|
||
```ts
|
||
import { UserProfilePopup, popupUserStore } from "timi-tdesign-pc";
|
||
|
||
// 决定弹层里展示谁
|
||
popupUserStore.user.value = user;
|
||
```
|
||
|
||
页面上需要同时放置两样东西:
|
||
|
||
- `<user-profile-popup />`:资料内容容器,只挂载一次
|
||
- `<popup />`:`timi-web` 的弹层容器,同样只挂载一次
|
||
|
||
然后在任意元素上用 `v-popup="popupUserStore.config"` 绑定悬停行为。弹层关闭后 `user` 会被自动清空。
|
||
|
||
## API
|
||
|
||
<api-table name="UserProfilePopup" />
|