智能照明系统APP-本地串口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
LightingSystemApp-serial/.svn/pristine/07/072bdbc65057496eb254d4e54bf...

49 lines
1.1 KiB

import {
debounce,
throttle
} from 'uni-shared'
import emitter from './emitter'
import keyboard from './keyboard'
export default {
name: 'BaseInput',
mixins: [emitter, keyboard],
model: {
prop: 'value',
event: 'update:value'
},
props: {
value: {
type: [String, Number],
default: ''
}
},
data () {
return {
valueSync: this._getValueString(this.value)
}
},
created () {
const valueChange = this.__valueChange = debounce((val) => {
this.valueSync = this._getValueString(val)
}, 100)
this.$watch('value', valueChange)
this.__triggerInput = throttle(($event, detail) => {
this.$emit('update:value', detail.value)
this.$trigger('input', $event, detail)
}, 100)
this.$triggerInput = ($event, detail) => {
this.__valueChange.cancel()
this.__triggerInput($event, detail)
}
},
beforeDestroy () {
this.__valueChange.cancel()
this.__triggerInput.cancel()
},
methods: {
_getValueString (value) {
return value === null ? '' : String(value)
}
}
}