vue2 ref

ref  绑定dom节点,拿到的就是dom对象

ref   绑定组件,拿到的就是组件对象

使用案列:

<input type='text' ref='mytext'/>

<input type='password' ref='myPassword'/>

console.log(this.$refs.mytext)   此时获取到的是input中的value值

console.log(this.$refs.myPassword) 此时获取到的是password的值

posted @ 2022-07-19 10:19  呼丿  阅读(128)  评论(0编辑  收藏  举报