Skip to content
On this page

Modal 模态框

利用vue3提供的组件Teleport,实现将Modal组件挂载到body标签下,避免样式问题导致的Modal错位

<template>
  <w-modal :show="show" @close="close">
    <template #header>
      <h1>哈哈哈</h1>
    </template>
  </w-modal>
  <w-button @click="open">打开</w-button>
</template>

<script setup>
import { ref } from 'vue'

const show = ref(false)

const open = () => {
  show.value = true
}
const close = () => {
  show.value = false
}
</script>

Modal属性

属性说明类型可选值默认值
show是否显示Modalboolean——false

Modal事件

事件名说明参数
close关闭Modal——