在父组件中引入子组件,通常需要在父组件调用子组件的方法。就用到了组件方法 this.refs
使用前 需要在子组件模板定义
ref方法名
例如:红框所示 ref="name" //name为自定义名字
image.png
父组件使用时 只需要调用
this.$refs.name.子组件方法(),就可以了。
this.refs
使用前 需要在子组件模板定义
ref方法名
例如:红框所示 ref="name" //name为自定义名字
image.png
父组件使用时 只需要调用
this.$refs.name.子组件方法(),就可以了。
本文标题:vue组件方法 ref &&this.refs
本文链接:https://www.haomeiwen.com/subject/vfpcbctx.html
网友评论