1.0.1 • Published 3 years ago

@ophiuchus/overlay v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Overlay 遮罩层

介绍

创建一个遮罩层,用于强调特定的页面元素,并阻止用户进行其他操作。

引入

import Vue from 'vue';
import Overlay from '@ophiuchus/overlay';

Vue.use(Overlay);

代码演示

基础用法

<sf-button type="primary" text="显示遮罩层" @click="show = true" />
<sf-overlay :show="show" @click="show = false" />
export default {
  data() {
    return {
      show: false
    }
  }
},

嵌入内容

通过默认插槽可以在遮罩层上嵌入任意内容。

<sf-overlay :show="show" @click="show = false">
  <div class="wrapper" @click.stop>
    <div class="block" />
  </div>
</sf-overlay>

<style>
  .wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
  }

  .block {
    width: 120px;
    height: 120px;
    background-color: #fff;
  }
</style>

API

Props

参数说明类型默认值
show是否展示遮罩层booleanfalse
z-indexz-index 层级number | string1
duration动画时长,单位秒number | string0.3
class-name自定义类名string-
custom-style自定义样式object-
lock-scroll是否锁定背景滚动,锁定时蒙层里的内容也将无法滚动booleantrue

Events

事件名说明回调参数
click点击时触发event: Event

Slots

名称说明
default默认插槽,用于在遮罩层上方嵌入内容

样式变量

组件提供了下列 Less 变量,可用于自定义样式,使用方法请参考主题定制

名称默认值描述
@overlay-z-index1-
@overlay-background-colorrgba(0, 0, 0, 0.7)-