element ui点击按钮弹出款_Element MessageBox弹框的具体使用

组件—弹框

消息提示

be7708f8ec838fe2b8251787fb35a9a9.png

58c2adc2fa9898c031802cd1cff2d085.png

点击打开 Message Box

export default {

methods: {

open() {

this.$alert('这是一段内容', '标题名称', {

confirmButtonText: '确定',

callback: action => {

this.$message({

type: 'info',

message: `action: ${ action }`

});

}

});

}

}

}

确认消息

24597a7afc616b9ab8306fe46668ed9c.png

d36abfe3c0545d3524bd97e55ba8b492.png

点击打开 Message Box

export default {

methods: {

open() {

this.$alert('这是一段内容', '标题名称', {

confirmButtonText: '确定',

callback: action => {

this.$message({

type: 'info',

message: `action: ${ action }`

});

}

});

}

}

}

提交内容

3cec839454c78f8cc1f90dd65395654e.png

cf482024c7d33fb0e0b6def0c09b7984.png

点击打开 Message Box

export default {

methods: {

open() {

this.$prompt('请输入邮箱', '提示', {

confirmButtonText: '确定',

cancelButtonText: '取消',

inputPattern: /[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/,

inputErrorMessage: '邮箱格式不正确'

}).then(({ value }) => {

this.$message({

type: 'success',

message: '你的邮箱是: ' + value

});

}).catch(() => {

this.$message({

type: 'info',

message: '取消输入'

});

});

}

}

}

自定义

71c7eaec6e4b68808e296b0338671999.png

f6bab48aba346b1dd859602c81d08296.png

点击打开 Message Box

export default {

methods: {

open() {

const h = this.$createElement;

this.$msgbox({

title: '消息',

message: h('p', null, [

h('span', null, '内容可以是 '),

h('i', { style: 'color: teal' }, 'VNode')

]),

showCancelButton: true,

confirmButtonText: '确定',

cancelButtonText: '取消',

beforeClose: (action, instance, done) => {

if (action === 'confirm') {

instance.confirmButtonLoading = true;

instance.confirmButtonText = '执行中...';

setTimeout(() => {

done();

setTimeout(() => {

instance.confirmButtonLoading = false;

}, 300);

}, 3000);

} else {

done();

}

}

}).then(action => {

this.$message({

type: 'info',

message: 'action: ' + action

});

});

}

}

}

使用 HTML 片段

d000dcd0dfac2811a43f50d926c87e73.png

5b5d559b728b894c911f663be3664702.png

点击打开 Message Box

export default {

methods: {

open() {

this.$alert('这是 HTML 片段', 'HTML 片段', {

dangerouslyUseHTMLString: true

});

}

}

}

区分取消与关闭

52209e604cd1b3e990933118896f12ea.png

9b9cc0ae63cc891e7c20122536d4afaa.png

点击打开 Message Box

export default {

methods: {

open() {

this.$alert('这是 HTML 片段', 'HTML 片段', {

dangerouslyUseHTMLString: true

});

}

}

}

居中布局

e1487010114ba046a309c8ee7bea99db.png

4004655fc4136e81d8f4835c74765714.png

点击打开 Message Box

export default {

methods: {

open() {

this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {

confirmButtonText: '确定',

cancelButtonText: '取消',

type: 'warning',

center: true

}).then(() => {

this.$message({

type: 'success',

message: '删除成功!'

});

}).catch(() => {

this.$message({

type: 'info',

message: '已取消删除'

});

});

}

}

}

全局方法

244139757e8a2e923339a5c3bbc89c10.png

单独引用

d5989413e00dc1c3b6c3611a84fee54b.png

Options

edd6f3b3437a204812580d22a2547b79.png

6b369505b6f73bddcac67a1213ca32a1.png

92783978c6c93f6f1d0b1eaa61b37e54.png

c8f0d76975f66482def9439b3c51e169.png

到此这篇关于Element MessageBox弹框的具体使用的文章就介绍到这了,更多相关Element MessageBox弹框内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!

时间: 2020-07-26

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值