Popup 弹出层 组件

介绍

弹出层容器,用于展示弹窗、信息提示等内容,支持多个弹出层叠加展示

安装

  1. import { createApp } from 'vue';
  2. import { Popup } from '@nutui/nutui';
  3. const app = createApp();
  4. app.use(Popup);

代码演示

基础用法

visible 控制显示/隐藏

  1. <nut-popup :style="{ padding: '30px' }" v-model:visible="show">正文</nut-popup>

弹出位置

  1. <nut-popup
  2. position="top"
  3. v-model:visible="show"
  4. :style="{ height: '20% }"
  5. ></nut-popup>
  6. <nut-popup
  7. position="left"
  8. v-model:visible="show"
  9. :style="{ height: '100%', width: '20%' }"
  10. ></nut-popup>

图标

  1. <nut-popup
  2. position="bottom"
  3. closeable
  4. :style="{ height: '20%' }"
  5. v-model:visible="show"
  6. ></nut-popup>
  7. <nut-popup
  8. position="bottom"
  9. closeable
  10. close-icon-position="top-left"
  11. :style="{ height: '20%' }"
  12. v-model:visible="show"
  13. ></nut-popup>
  14. <nut-popup
  15. position="bottom"
  16. closeable
  17. close-icon-position="top-left"
  18. close-icon="heart"
  19. :style="{ height: '20%' }"
  20. v-model:visible="show"
  21. ></nut-popup>

圆角弹框

  1. <nut-popup
  2. position="bottom"
  3. closeable
  4. round
  5. :style="{ height: '30%' }"
  6. v-model:visible="show"
  7. ></nut-popup>

指定挂载节点

  1. <nut-popup :style="{ padding: '30px' }" teleport="#app" v-model:visible="show">app</nut-popup>

API

Props

参数说明类型默认值
v-model:visible当前组件是否显示Booleanfalse
z-index遮罩层级String、Number2000
duration动画时长,单位秒String、Number0.3
overlay-class自定义遮罩类名String-
overlay-style自定义遮罩样式CSSProperties-
lock-scroll背景是否锁定Booleanfalse
overlay是否显示遮罩Booleantrue
close-on-click-overlay是否点击遮罩关闭Booleantrue
position弹出位置(top,bottom,left,right,center)String“center”
transition动画名String-
style自定义弹框样式CSSProperties-
pop-class自定义弹框类名String-
closeable是否显示关闭按钮Booleanfalse
close-icon-position关闭按钮位置(top-left,top-right,bottom-left,bottom-right)String“top-right”
close-icon自定义 IconString“close”
destroy-on-close组件销毁后是否关闭Booleantrue
round是否显示圆角Booleanfalse
teleport指定挂载节点String“body”

Events

事件名说明回调参数
click点击弹框时触发event: Event
click-close-icon点击关闭图标时触发event: Event
open打开弹框时触发-
close关闭弹框时触发-
opend遮罩打开动画结束时触发event: Event
closed遮罩关闭动画结束时触发event: Event
click-overlay点击遮罩触发event: Event

Popup  弹出层 - 图1