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)
}
}