1、使用this.$refs如果要在mouend()中使用,必须要在this.$nextTick(()=>{ } ) 这里面实现,要不是找不到ref,原因是mouned()之后,BOM节点还没有完全挂载上,于是找不到定义的ref。
2、可以直接在updata()的生命周期函数中使用,不用写this.$nextTick(()=>{ } )
3、在methods:{ } 方法中使用,也需要使用this.$nextTick(()=>{ } ) 等到页面完全渲染完毕之后在调用即可
1、使用this.$refs如果要在mouend()中使用,必须要在this.$nextTick(()=>{ } ) 这里面实现,要不是找不到ref,原因是mouned()之后,BOM节点还没有完全挂载上,于是找不到定义的ref。
2、可以直接在updata()的生命周期函数中使用,不用写this.$nextTick(()=>{ } )
3、在methods:{ } 方法中使用,也需要使用this.$nextTick(()=>{ } ) 等到页面完全渲染完毕之后在调用即可