Child component pass 1. Create a button in the child component and bind the button with a click event 2. Use $emit to fire a custom event and pass parameters

<template> <div> <el-row> <el-button type="primary" plain @click="set"> </el-button> </el-row> </div> </template> <script> export default { data() { return {}; {}, the methods: {set () enclosing $emit (" sonSet, "[{name:" zhang ", id: 1}, {name: "bill", id: 2}]); }}}; </script>Copy the code

Parent component fath 1. Listens for event name 2 defined by the child component in the child tag of the parent component. Gets the passed value

<template> <div> <Pass @sonSet="getlist"></Pass> </div> </template> <script> import Pass from ".. /components/Pass"; export default { data() { return { }; }, components: { Pass }, getlist(e){ console.log(e) } }, }; </script>Copy the code