Skip to content

Dialog 弹出框

基础用法

html
<script setup lang="ts">
import { ref } from 'vue'
import { DialogInst, DialogOptions } from 'ano-ui'

const dialog = ref<DialogInst>()

function showDialog(options: DialogOptions) {
  dialog.value?.show(options)
}
</script>

<template>
  <ADialog ref="dialog" />
  <AButton @click="showDialog({ title: '标题', message: '这是一个弹出框' })">
    展示弹出框
  </AButton>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { DialogInst, DialogOptions } from 'ano-ui'

const dialog = ref<DialogInst>()

function showDialog(options: DialogOptions) {
  dialog.value?.show(options)
}
</script>

<template>
  <ADialog ref="dialog" />
  <AButton @click="showDialog({ title: '标题', message: '这是一个弹出框' })">
    展示弹出框
  </AButton>
</template>

消息确认

用于确认消息,包含取消和确认按钮。

html
<script setup lang="ts">
import { ref } from 'vue'
import { DialogInst, DialogOptions } from 'ano-ui'

const dialog = ref<DialogInst>()

function showDialog(options: DialogOptions) {
  dialog.value?.show(options)
}
</script>

<template>
  <ADialog ref="dialog" />
  <AButton @click="showDialog({ title: '标题', message: '这是一个弹出框', showCancelButton: true })">
    展示弹出框
  </AButton>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { DialogInst, DialogOptions } from 'ano-ui'

const dialog = ref<DialogInst>()

function showDialog(options: DialogOptions) {
  dialog.value?.show(options)
}
</script>

<template>
  <ADialog ref="dialog" />
  <AButton @click="showDialog({ title: '标题', message: '这是一个弹出框', showCancelButton: true })">
    展示弹出框
  </AButton>
</template>

API

DialogOptions 数据结构

参数说明类型默认值
title标题string-
message内容string-
showCancelButton是否展示取消按钮booleanfalse
showConfirmButton是否展示确认按钮booleantrue
cancelButtonText取消按钮文本string取消
confirmButtonText确认按钮文本string确认

Events

事件名说明回调参数
confirm点击确认按钮时触发-
cancel点击取消按钮时触发-

MIT Licensed