📌  相关文章
📜  如何从子组件调用父方法 - Html 代码示例

📅  最后修改于: 2022-03-11 14:52:54.205000             🧑  作者: Mango

代码示例1
You should use this.$emit('myEvent') inside of your child component, when you want to trigger the method in the parent.

Then find you child component in the template of the parent and add an event catcher on it like this:


If you want to add parameters to your method, you can add a second parameter to your emit like this:

this.$emit("myEvent", "My parameter")
For this to work you don't have to change anything in the event "catcher", as long as the method you call has a parameter