neverland bd609e1df0
perf: add truthProp util (#8522)
* perf: add TruthyProp util

* chore: rename

* chore: upd
2021-04-14 10:26:21 +08:00
..
2020-12-15 17:01:55 +08:00
2021-03-09 15:39:26 +08:00
2021-04-14 10:26:21 +08:00
2021-04-08 09:57:55 +08:00
2021-03-17 16:14:18 +08:00

Overlay

Intro

Create a mask layer to emphasize specific page elements and prevent users from performing other operations.

Install

Register component globally via app.use, refer to Component Registration for more registration ways.

import { createApp } from 'vue';
import { Overlay } from 'vant';

const app = createApp();
app.use(Overlay);

Usage

Basic Usage

<van-button type="primary" text="Show Overlay" @click="show = true" />
<van-overlay :show="show" @click="show = false" />
import { ref } from 'vue';

export default {
  setup() {
    const show = ref(false);
    return { show };
  },
};

Embedded Content

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

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

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

API

Props

Attribute Description Type Default
show Whether to show overlay boolean false
z-index z-index number | string 1
duration Animation duration number | string 0.3
class-name ClassName string -
custom-class Custom style object -
lock-scroll Whether to lock background scroll boolean true

Events

Event Description Arguments
click Emitted when component is clicked event: MouseEvent

Slots

Name Description
default Default slot

Less Variables

How to use: Custom Theme.

Name Default Value Description
@overlay-z-index 1 -
@overlay-background-color rgba(0, 0, 0, 0.7) -