Created
August 16, 2018 12:27
-
-
Save magicianShiro/4cd14f5d13fb2e1a8db308d3598c25e2 to your computer and use it in GitHub Desktop.
mpvue中input 使用 v-model 导致光标抖动
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const vModelBugfillMixin = { | |
data() { | |
return { | |
ownValue: null, | |
}; | |
}, | |
model: { | |
prop: 'valueFromProp', | |
}, | |
props: { | |
valueFromProp: { | |
type: String, | |
}, | |
}, | |
computed: { | |
value() { | |
return this.ownValue == null ? this.valueFromProp : this.ownValue; | |
}, | |
}, | |
methods: { | |
onChange(event) { | |
this.ownValue = event.target.value; | |
setTimeout(() => this.$emit('input', event.target.value)); | |
}, | |
}, | |
}; | |
// 详情看 https://github.com/Meituan-Dianping/mpvue/issues/241 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment