Skip to content

Message 弹窗

常用于消息提示。

基础使用

查看代码
vue
<template>
	<demo-container>
		<gov-button @click="handleClick">点击弹出Message</gov-button>
	</demo-container>
</template>

<script setup>
import { GovMessage } from "@/dist/index.js";

const handleClick = () => {
	GovMessage("Hello Word!");
};
</script>

不同类型

弹出不同风格的 message

查看代码
vue
<template>
	<demo-container>
		<gov-button @click="handleClick('default')">默认</gov-button>
		<gov-button @click="handleClick('primary')" type="primary">
			主要
		</gov-button>
		<gov-button @click="handleClick('success')" type="success">
			成功
		</gov-button>
		<gov-button @click="handleClick('info')" type="info">信息</gov-button>
		<gov-button @click="handleClick('warning')" type="warning">
			警告
		</gov-button>
		<gov-button @click="handleClick('danger')" type="danger">
			危险
		</gov-button>
	</demo-container>
</template>

<script setup>
import { GovMessage } from "@/dist/index.js";

const handleClick = (type) => {
	GovMessage({
		type,
		message: `打开 ${type} 类型的消息`,
	});
};
</script>

更多控制

支持 html,时长,是否有关闭按钮等。

查看代码
vue
<template>
	<demo-container>
		<gov-button @click="handleClick">点击查看</gov-button>
	</demo-container>
</template>

<script setup>
import { GovMessage } from "@/dist/index.js";

const handleClick = () => {
	GovMessage({
		type: "primary",
		duration: 4000,
		closable: true,
		message:
			"您正在访问<b style='color:red'>GovUI</b>,<i>祝您心情愉快!</i>",
	})
		.then(() => {
			console.log("已经打开!");
		})
		.catch(() => {
			console.log("已经关闭!");
		});
};
</script>

关闭所有

在任意实例上关闭所有弹窗。

查看代码
vue
<template>
	<demo-container>
		<gov-button @click="handleClick">点击弹出Message</gov-button>
		<gov-button @click="hancleCloseAll">点击关闭所有</gov-button>
	</demo-container>
</template>

<script setup>
import { GovMessage } from "@/dist/index.js";

const handleClick = () => {
	GovMessage("Hello Word!");
};

const hancleCloseAll = () => {
	GovMessage.closeAll();
};
</script>

Options

属性名说明类型可选值默认值
message消息内容String
duration显示时长Number3000
type消息类型Stringdefault, primary, success, info, warning, dangerdefault
icon图标名称String
customClass自定义类名String
onBeforeOpen打开前的回调函数Function
onOpend打开后的回调函数Function
onBeforeClose关闭前的回调函数Function
onClosed关闭后的回调函数Function
closable是否显示关闭按钮Booleantrue, falsefalse

Methods

方法名说明参数返回值
closeAll关闭所有 message 弹窗

Released under the MIT License.