Popup 弹出层请使用手机扫码体验

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

基本功能

  1. html
    <nut-cell isLink title="展示弹出层" :showIcon="true" @click.native="show= true">
  2. </nut-cell>
  3. <nut-popup :style="{ padding: '30px 50px' }" v-model="show">正文</nut-popup>
  1. javascript
    export default {
  2. data() {
  3. return {
  4. show: false
  5. };
  6. },
  7. methods: {
  8. showPopup() {
  9. this.show = true;
  10. }
  11. }
  12. };

弹出位置

通过 position 属性设置弹出位置,默认居中弹出,可以设置为 top、bottom、left、right

  1. html
    <nut-popup v-model="show" position="top" :style="{ height: '20%' }" />

关闭图标

设置closeable属性后,会在弹出层的右上角显示关闭图标,并且可以通过close-icon属性自定义图标,使用close-icon-position属性可以自定义图标位置

  1. html
    <nut-popup position="bottom" closeable close-icon="tick" v-model="showCloseIcon" :style="{ height: '20%' }" close-icon-position="top-left"></nut-popup>

圆角弹窗

设置 round 属性后,弹窗会根据弹出位置添加不同的圆角样式

  1. html
    <nut-popup v-model="show" round position="bottom" :style="{ height: '20%' }" />

指定挂载位置

弹出层默认挂载到组件所在位置,可以通过get-container属性指定挂载位置

  1. html
    <!-- 挂载到 body 节点下 -->
  2. <nut-popup v-model="show" get-container="body" />
  3. <!-- 挂载到 #app 节点下 -->
  4. <nut-popup v-model="show" get-container="#app" />

API

字段说明类型默认值
v-model当前组件是否显示boolean-
overlay是否显示遮罩层booleantrue
position弹出位置,可选值为 top bottom right left centerstringcenter
duration动画时长,单位秒Number-
round是否显示圆角boolean-
transition动画类名,等价于 transtion 的 name 属性string-
closeable是否显示关闭图标Booleanfalse
close-icon关闭图标名称stringcross
close-icon-position关闭图标位置,可选值为top-left top-right bottom-left bottom-rightstringtop-right
destroy-on-close控制是否在关闭 popop 之后将子元素全部销毁booleanfalse
overlay-class自定义遮罩层类名string
overlay-style自定义遮罩层样式object
lock-scroll是否锁定背景滚动booleantrue
close-on-click-overlay是否在点击遮罩层后关闭booleantrue
get-container指定挂载节点string

Event

事件名说明
click点击弹出层时触发
open打开弹出层时触发
close关闭弹出层时触发
opened打开弹出层且动画结束后触发
closed关闭弹出层且动画结束后触发
click-overlay点击遮罩层时触发

Popup 弹出层 - 图1