leiyanting

导航

 

nextTick

  1. 语法:this.$nextTick(回调函数)
  2. 作用:在下一次 DOM 更新结束后执行其指定的回调。
  3. 什么时候用:当改变数据后,要基于更新后的新DOM进行某些操作时,要在nextTick所指定的回调函数中执行。
			//编辑
			handleEdit(todo){
				if(todo.hasOwnProperty('isEdit')){
					todo.isEdit = true
				}else{
					// console.log('@')
					this.$set(todo,'isEdit',true)
				}
				//在下一次 DOM 更新结束后执行其指定的回调
				this.$nextTick(function(){
					this.$refs.inputTitle.focus()
				})
			}
posted on 2021-11-19 19:51  leiyanting  阅读(313)  评论(0)    收藏  举报