1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<template>
<ion-toggle
class="app-mob-switch"
:checked="curValue"
@ionChange="change"
@ionFocus="enter"
@ionBlur="leave"
:disabled="disabled"
>
</ion-toggle>
</template>
<script lang="ts">
import { Vue, Component, Prop, Provide, Emit, Watch } from 'vue-property-decorator';
@Component({
components: {
}
})
export default class AppMobSwitch extends Vue {
/**
* checked选中状态
*
* @type {boolean}
* @memberof AppMobSwitch
*/
@Prop() public value?: any;
/**
* 编辑器名称
*
* @type {string}
* @memberof AppMobSwitch
*/
@Prop() public name?:string;
/**
* 禁用
*
* @type {boolean}
* @memberof AppMobSwitch
*/
@Prop({default:false}) public disabled?:boolean;
get curValue(){
return this.value == 1 ? true:false;
}
/**
* change事件
*
* @memberof AppMobSwitch
*/
public change(value:any){
this.$emit('change',{ name:this.name , value:value.detail.checked == true ? '1':'0', event:{}});
}
/**
* 有焦点时事件
*
* @memberof AppMobSwitch
*/
public enter(e: any) {
this.$emit('enter', {name: this.name, value: this.value, event:e});
}
/**
* 失去焦点事件
*
* @memberof AppMobSwitch
*/
public leave(e: any) {
this.$emit('leave', {name: this.name, value: this.value, event:e});
}
}
</script>