ref属性是vue2中的一种属性,用来注册组件或元素的引用信息,或者说是另一种id
- 应用在html标签里,返回的就是整个DOM元素
- 应用在组件里,返回的就是VueComponent实例对象
如何使用
// to use ref in tags/components
<h1 ref="demo">hello!</h1>
<School ref="demo"/>
// to retrieve the value by ref
this.$refs.demo
ref属性是vue2中的一种属性,用来注册组件或元素的引用信息,或者说是另一种id
// to use ref in tags/components
<h1 ref="demo">hello!</h1>
<School ref="demo"/>
// to retrieve the value by ref
this.$refs.demo