更新时间:2023-10-27 20:49:04
我之前遇到过类似的问题,我***更新(在您的情况下,焦点
),使用Vue的 nextTick
方法,该方法将立即使用已经更改了一些数据以等待DOM更新。:
I encountered a similar problem before, and I forced the update (in your case, the focus
) by using Vue's nextTick
method, which is to use immediately after you’ve changed some data to wait for the DOM update.:
this.$nextTick(() => {
this.$refs.questionInput.focus();
})