Skip to content

Instantly share code, notes, and snippets.

@magicianShiro
Created August 16, 2018 12:27
Show Gist options
  • Save magicianShiro/4cd14f5d13fb2e1a8db308d3598c25e2 to your computer and use it in GitHub Desktop.
Save magicianShiro/4cd14f5d13fb2e1a8db308d3598c25e2 to your computer and use it in GitHub Desktop.
mpvue中input 使用 v-model 导致光标抖动
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