Home> Web Front-end> Vue.js> body text

How to call the method of child component in vue parent component

青灯夜游
Release: 2021-10-26 14:28:20
Original
120925 people have browsed it

Calling method: 1. In the parent component, directly call the child component's method through ref; 2. In the parent component, call through the component's "$emit" and "$on" methods.

How to call the method of child component in vue parent component

The operating environment of this tutorial: windows7 system, vue2.9.6 version, DELL G3 computer.

How to directly call the child component in the parent component in the Vue project:

Option 1: Directly call the child through ref Component method;

//父组件中   //子组件中  
Copy after login

Option 2: Through the $emit and $on methods of the component;

//父组件中   //子组件中  
Copy after login

Related recommendations: "vue.js Tutorial

The above is the detailed content of How to call the method of child component in vue parent component. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn