1.0.5 • Published 2 years ago

vuetify-message-box v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

vuetify-message-box

基于 vue2 + vuetify 的消息弹框组件

使用方法

安装

npm i vuetify-message-box

引入

import Vue from 'vue'
import Vuetify from 'vuetify'
import VuetifyMessageBox from 'vuetify-message-box'
const vuetify = new Vuetify({})
Vue.use(Vuetify)
Vue.use(VuetifyMessageBox, {
	vuetify
})

调用

<script>
export default {
	methods: {
		msgbox (mode = '默认') {
			if (mode === '默认') {
				// 只传入消息内容
				this.$msgbox('hello world')
			} else if (mode === '带选项1') {
				// 传入消息内容, 选项
				this.$msgbox('hello world', {
					center: true
				})
			} else if (mode === '带选项2') {
				// 只传入选项, 消息内容在选项中
				this.$msgbox({
					message: 'hello world',
					center: true
				})
			} else if (mode === '按类型') {
				// success error warning info
				this.$msgbox.success({
					message: 'hello world',
					center: true
				})
			} else if (mode === '使用VNode') {
				this.$msgbox({
					content: this.$createElement('div', {
						style: {
							color: 'red'
						}
					}, 'hello world')
				})
			} else if (mode === '关闭最后一个') {
				this.$msgbox('消息1', { name: 'msg1' })
				this.$msgbox('消息2', { name: 'msg2' })
				setTimeout(() => {
					this.$msgbox.close()
				}, 3e3)
			} else if (mode === '关闭指定name') {
				this.$msgbox('消息1', { name: 'msg1' })
				this.$msgbox('消息2', { name: 'msg2' })
				setTimeout(() => {
					this.$msgbox.close('msg1')
				}, 3e3)
			}
		}
	}
}

</script>

选项

属性类型默认值说明
titlestring'消息提示'标题
widthstring, number400组件宽度
centerbooleantrue是否居中显示
darkbooleanfalse是否使用暗色主题
typestring''消息类型 'success', 'error', 'warning', 'info'
iconboolean, string-消息图标, 默认根据type显示, false则不显示
closeIconstring''关闭按钮图标
contentClassstring''消息内容类名
messagestring''消息文本, 与content属性互斥, 优先级高
contentvnodenull消息内容节点
prependvnodenull按钮前置内容
appendvnodenull按钮后置内容
showConfirmButtonbooleantrue是否显示确认按钮
confirmButtonTextstring'确定'确认按钮文本
confirmButtonClassstring''确认按钮类名
showCancelButtonbooleantrue是否显示取消按钮
cancelButtonTextstring'取消'取消按钮文本
cancelButtonClassstring''确认按钮类名
closeOnClickModalbooleantrue点击遮罩是否关闭
silencebooleanfalse是否关闭reject提示, 为true时, 最好在同一eventLoop周期内调用then/catch, 不然原有回调的参数会被丢弃

License

MIT

1.0.5

2 years ago

1.0.4

3 years ago

1.0.2

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago