html messagebox确定取消,Element MessageBox弹框的具体使用

组件—弹框

消息提示

4afc7f54c14a1411255364c3a24c082e.png

6f369f3088863ed97480e6db3677d67d.png

点击打开 Message Box

export default {

methods: {

open() {

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

confirmButtonText: '确定',

callback: action => {

this.$message({

type: 'info',

message: `action: ${ action }`

});

}

});

}

}

}

确认消息

c5bda1faeb8644c2fad3c32bb099ae36.png

463be606eb72f74865f4da78e4049842.png

点击打开 Message Box

export default {

methods: {

open() {

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

confirmButtonText: '确定',

callback: action => {

this.$message({

type: 'info',

message: `action: ${ action }`

});

}

});

}

}

}

提交内容

48a711fd266e67bfa46b4659873396d4.png

6ea60d384e3425b95532c9f1b2d5420b.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: '取消输入'

});

});

}

}

}

自定义

eaea27608b4e94a62437719d21bdc0e5.png

de4ac6794a17e7c93d0b0c4e827af175.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 片段

901556004c3a6075c0757f3a78da613a.png

1b0388be75dee2a316bbb3ac598ef53c.png

点击打开 Message Box

export default {

methods: {

open() {

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

dangerouslyUseHTMLString: true

});

}

}

}

区分取消与关闭

b193cdd83283ab13a551edfa2f4e1b85.png

2438865cda8696fc9481d9e7c39ec594.png

点击打开 Message Box

export default {

methods: {

open() {

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

dangerouslyUseHTMLString: true

});

}

}

}

居中布局

a1c7f69e0d5d6b69bd679f141f0c20b5.png

1b6952b8608599457d7ee3e124183362.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: '已取消删除'

});

});

}

}

}

全局方法

932456cd6e17f576abfe11c01c51bd6e.png

单独引用

5e70bb16a65beff18c792385898c9e95.png

Options

e59ac7756ffee7714b8233d200957f39.png

8eb6dddbafabaee2ec0a8ffd90bd4845.png

23c34f31f76eb8ce18d949faffe9535a.png

379a61c2fe011737a0cf64db96065356.png

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值