Switch add new prop: beforeChange

This commit is contained in:
梁灏 2019-09-05 14:22:07 +08:00
parent 485db11ee2
commit ae2031aea1
2 changed files with 38 additions and 8 deletions

View file

@ -1,6 +1,6 @@
<template>
<div>
<i-switch v-model="m1" :loading="loading">
<i-switch v-model="m1" :loading="loading" @on-change="change" :before-change="beforeChange">
<span slot="open"></span>
<span slot="close"></span>
</i-switch>
@ -49,6 +49,20 @@
methods: {
change (status) {
console.log(status)
},
beforeChange () {
return new Promise((resolve, reject) => {
this.$Modal.confirm({
title: '切换确认',
content: '您确认要切换开关状态吗?',
onOk: () => {
resolve();
},
onCancel: () => {
reject();
}
});
});
}
}
}