App.vue
<template>
<div id="app">
<Parent></Parent>
</div>
</template>
<script>
import Parent from './components/Parent'
export default {
name: 'App',
components: {
Parent
}
}
</script>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
components/Parent.vue
<template>
<div>
<span>我是父组件</span>
<Child ref="Child"></Child>
</div>
</template>
<script>
import Child from './Child';
export default {
components: {
Child,
},
mounted () {
conso