Vue $nextTick
$nextTick
$nextTick在下一次dom更新结束之后执行
数据改变后,如果要基于新数据的dom去做一些事情,使用\(nextTick,操作\)nextTick的回调去处理
案例
editTask(item) {
if (Object.prototype.hasOwnProperty.call(item, "isEdit")) {
item.isEdit = true;
} else {
this.$set(item, "isEdit", true);
}
this.$nextTick(() => {
this.$refs.title.focus();
});
}

浙公网安备 33010602011771号