mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix: field 计算autosize,需要nextTick (#78)
* textarea sizeAdjust 需要nextTick * fix field unit test
This commit is contained in:
parent
a3ce58e0be
commit
97c54d7f13
@ -101,7 +101,9 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
currentValue(val) {
|
currentValue(val) {
|
||||||
if (this.autosize && this.type === 'textarea') this.sizeAdjust();
|
if (this.autosize && this.type === 'textarea') {
|
||||||
|
this.$nextTick(() => this.sizeAdjust());
|
||||||
|
}
|
||||||
this.$emit('input', val);
|
this.$emit('input', val);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -120,10 +120,10 @@ describe('Field', () => {
|
|||||||
textarea.trigger('input');
|
textarea.trigger('input');
|
||||||
|
|
||||||
wrapper.update();
|
wrapper.update();
|
||||||
wrapper.vm.$nextTick(() => {
|
setTimeout(() => {
|
||||||
expect(wrapper.data().currentValue).to.equal('test');
|
expect(wrapper.data().currentValue).to.equal('test');
|
||||||
expect(textareaElement.style.height).to.equal((textareaElement.scrollHeight - textAreaDiff) + 'px');
|
expect(textareaElement.style.height).to.equal((textareaElement.scrollHeight - textAreaDiff) + 'px');
|
||||||
done();
|
done();
|
||||||
});
|
}, 500);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user