vue组件方法 ref &&this.refs

在父组件中引入子组件,通常需要在父组件调用子组件的方法。就用到了组件方法 this.refs

使用前 需要在子组件模板定义 ref方法名

例如:红框所示 ref="name" //name为自定义名字

vue组件方法 ref &&this.refs_第1张图片

 父组件使用时 只需要调用 this.$refs.name.子组件方法(),就可以了。

你可能感兴趣的:(vue.js,javascript,ecmascript)