Skip to content

Modal 模态框

在保留当前页面状态的情况下,告知用户并承载相关操作。

基础用法

<template>
	<LiButton @click="handleModal">徐然</LiButton>
	<LiModal
		:show="showModal"
		title="提示"
		content="Licht UI 是一个基于Vue3开发的轻量级组件库"
		@on-ok="showModal = !showModal"
		@on-cancle="showModal = !showModal"
	/>
</template>
<script setup lang="ts">
	import { ref } from "vue";

	const showModal = ref(false);
	const handleModal = () => (showModal.value = !showModal.value);
</script>
<style scope lang="scss"></style>

按钮文本

使用ok-textcancle-text控制

<template>
	<LiButton @click="handleModal">徐然</LiButton>
	<LiModal
		:show="showModal"
		title="提示"
		content="Licht UI 是一个基于Vue3开发的轻量级组件库"
		ok-text="我是徐然"
		cancle-text="我是好像不是徐然"
		@on-ok="showModal = !showModal"
		@on-cancle="showModal = !showModal"
	/>
</template>
<script setup lang="ts">
	import { ref } from "vue";

	const showModal = ref(false);
	const handleModal = () => (showModal.value = !showModal.value);
</script>
<style scope lang="scss"></style>

插槽

<template>
	<LiButton @click="handleModal">徐然</LiButton>
	<LiModal
		:show="showModal"
		@on-ok="showModal = !showModal"
		@on-cancle="showModal = !showModal"
	>
		<template #title> 插槽标题 </template>
		<template #default> 插槽内容 </template>
	</LiModal>
</template>
<script setup lang="ts">
	import { ref } from "vue";

	const showModal = ref(false);
	const handleModal = () => (showModal.value = !showModal.value);
</script>
<style scope lang="scss"></style>

message Attributes

参数说明类型可选值默认值
type类型stringdefault / primary / success / warning / info / dangerdefault
duration退出时间number2000
closed是否可以关闭booleanfalse
location位置stringleft / middle / rightleft
插槽名作用域参数说明
[title]标题
-内容

Released under the MIT License.