vue组件方法 ref &&this.refs
2019-11-02 本文已影响0人
不会写代码的机器人
在父组件中引入子组件,通常需要在父组件调用子组件的方法。就用到了组件方法 this.refs
使用前 需要在子组件模板定义
ref
方法名
例如:红框所示 ref="name"
//name为自定义名字

父组件使用时 只需要调用
this.$refs.name.子组件方法()
,就可以了。
this.refs
使用前 需要在子组件模板定义
ref
方法名
例如:红框所示 ref="name"
//name为自定义名字
父组件使用时 只需要调用
this.$refs.name.子组件方法()
,就可以了。