From 7b4f8bb7dcc30a2d372415b3851c9f88e0ed0384 Mon Sep 17 00:00:00 2001 From: roger_home_pc Date: Sun, 5 Feb 2023 22:26:33 +0800 Subject: [PATCH] =?UTF-8?q?todolist,=20=E4=BF=AE=E6=94=B9=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E6=97=B6=E4=B8=BA=E7=A9=BA=E7=9A=84=E5=A4=84=E7=90=86?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E6=B7=BB=E5=8A=A0nextTick=E7=9A=84?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=96=B9=E6=B3=95=E5=AD=A6=E4=B9=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 20_脚手架/vue_code/src/components/TodoItem.vue | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/20_脚手架/vue_code/src/components/TodoItem.vue b/20_脚手架/vue_code/src/components/TodoItem.vue index 027b8fe..04c5b46 100644 --- a/20_脚手架/vue_code/src/components/TodoItem.vue +++ b/20_脚手架/vue_code/src/components/TodoItem.vue @@ -3,7 +3,7 @@ @@ -35,12 +35,15 @@ export default { }else { this.$set(todo, 'isEdit', true) } + this.$nextTick(function () { + this.$refs.inputFocus.focus() + }) }, // 失去焦点时更新数据 handleBlur(todo, e) { todo.isEdit = false - // console.log('updateTodo', todo.id, e.target.value) - if (e.target.value.trim()) return alert("输入不能为空!") + console.log('updateTodo', todo.id, e.target.value) + if (!e.target.value.trim()) return alert("输入不能为空!") this.$bus.$emit('updateTodo', todo.id, e.target.value) } }