声明:本站文章均为作者个人原创,图片均为实际截图。如有需要请收藏网站,禁止转载,谢谢配合!!!

1、this.$forceUpdate()
在方法第一行使用,强制更新数据,常用于数组更新

changeValue(){
    this.$forceUpdate()
    this.users.push('badianboke')
}

2、this.$nextTick()
一般在方法末尾使用,当页面上元素被重新渲染之后,才会指定回调函数中的代码

changeValue(){
    this.saveInputVisible = true
    this.$nextTick(_ => {
        this.$refs.saveInput.$refs.input.focus()
    })
}

3、this.$set
有时候数据已经更新了,但是视图并没有更新,可以使用此方法解决

changeValue(){
    this.$set(this.user, 1, 'badianboke')
}



点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论