UNPKG

vant-fork

Version:

Lightweight Mobile UI Components built on Vue

50 lines (47 loc) 972 B
import create from '../utils/create'; export default create({ render: function render() { var _vm = this; var _h = _vm.$createElement; var _c = _vm._self._c || _h; return _c('div', { class: _vm.b({ on: _vm.value, disabled: _vm.disabled }), style: _vm.style, on: { "click": _vm.onClick } }, [_c('div', { class: _vm.b('node') }, [_vm.loading ? _c('loading', { class: _vm.b('loading') }) : _vm._e()], 1)]); }, name: 'switch', props: { value: Boolean, loading: Boolean, disabled: Boolean, size: { type: String, default: '30px' } }, computed: { style: function style() { return { fontSize: this.size }; } }, methods: { onClick: function onClick() { if (!this.disabled && !this.loading) { this.$emit('input', !this.value); this.$emit('change', !this.value); } } } });