iview/examples/routers/switch.vue

70 lines
2.2 KiB
Vue
Raw Normal View History

<template>
2017-03-02 11:19:00 +08:00
<div>
2019-09-06 15:38:26 +08:00
<i-switch v-model="m1" :loading="loading" @on-change="change" :before-change="beforeChange">
2017-03-02 11:19:00 +08:00
<span slot="open"></span>
<span slot="close"></span>
</i-switch>
{{ m1 }}
2018-06-22 10:14:13 +08:00
<div @click="m1 = !m1">toggle</div>
<div @click="loading = !loading">loading</div>
2018-06-21 19:51:38 +08:00
<br><br>
2018-06-22 10:14:13 +08:00
<i-switch size="large" loading></i-switch>
2018-06-21 19:51:38 +08:00
<i-switch></i-switch>
2018-06-22 10:14:13 +08:00
<i-switch size="small" v-model="m1" :loading="loading"></i-switch>
2018-06-21 19:51:38 +08:00
<br><br>
<i-switch>
<span slot="open"></span>
<span slot="close"></span>
</i-switch>
<i-switch>
2018-07-03 10:03:13 +08:00
<Icon type="md-checkmark" slot="open"></Icon>
<Icon type="md-close" slot="close"></Icon>
2018-06-21 19:51:38 +08:00
</i-switch>
<br><br>
<i-switch size="large">
<span slot="open">开启</span>
<span slot="close">关闭</span>
</i-switch>
2018-06-22 10:14:13 +08:00
<i-switch size="large" v-model="m1" :loading="loading">
2018-06-21 19:51:38 +08:00
<span slot="open">ON</span>
<span slot="close">OFF</span>
</i-switch>
<br><br>
<i-switch :disabled="disabled"></i-switch>
<Button type="primary" @click="disabled = !disabled">Toggle Disabled</Button>
2019-09-06 15:38:26 +08:00
<Divider></Divider>
<i-switch v-model="switch1" true-color="#13ce66" false-color="#ff4949" />
2017-03-02 11:19:00 +08:00
</div>
</template>
<script>
export default {
data () {
return {
2018-06-22 10:14:13 +08:00
m1: true,
disabled: true,
loading: false,
2019-09-06 15:38:26 +08:00
switch1: true
}
},
methods: {
change (status) {
2017-03-02 11:19:00 +08:00
console.log(status)
2019-09-06 15:38:26 +08:00
},
beforeChange () {
return new Promise((resolve, reject) => {
this.$Modal.confirm({
title: '切换确认',
content: '您确认要切换开关状态吗?',
onOk: () => {
resolve();
},
onCancel: () => {
reject();
}
});
});
}
}
}
</script>