这是一篇深夜博客,主要介绍了 Vue 中子组件给父组件传值,用 $emit( ) 实现
首先是建立 Vue 项目,删除 Helloworld.vue 及相关代码, 新建 Father.vue 和 Child.vue 两个文件,在 App.vue 中引入 Father.vue
App.vue
<template>
<div id="app">
<Father></Father>
</div>
</template>
<script>
import Father from "./components/Father";
export default {
name: 'App',
components: {
Father
}
}
</script>
<style>
#app {
}
</style&g