Today encountered when developing the front page of a problem, sub-assemblies to achieve a form after form submission to hide this page and jump, the parent is in the form of the parent element, a good solution to jump directly to this. $ Router.replace ( '/ url') on the bin. So how parent trigger the above incident? Later I checked the data and found that emit the good things, here are some code snippets:
Parent component:
<template> <addcz @closecz="closecz"></addcz> </template> <script> export default { components: { addcz }, methods: { closecz(){ this.czpanel = false } } } </script>
Subassembly:
<script> export default { methods: { submit_add() { //代码逻辑 this.$emit('closecz') }, } </script>
Subassemblies through this. $ Emit ( "Custom Event"), then the parent component to add custom events @ directly in the component = "event" can be achieved