App.vue
InfoBox.vue
main.js
 
<template>
  <h2>Example $parent Object</h2>
  <p>The 'text' data property can be reached and manipulated directly from the child component by the use of the $parent object.</p>
  <pre>{{ text }}</pre>
  <info-box />
</template>

<script>
export default {
  data() {
    return {
      text: 'Initial text in the parent component.'
    }
  }
}
</script>

<style>
pre {
  background-color: lightgreen;
  padding: 5px;
}
</style>                  
<template>
  <div>
    <h3>Change Text</h3>
    <p>Click the button to toggle the text in the PRE tag of the parent component.</p>
    <button v-on:click="this.$parent.text='Hello!'">Change text in parent</button>
  </div>
</template>

<style scoped>
div {
  border: solid black 1px;
  padding: 10px;
  width: 250px;
}
</style>                  
import { createApp } from 'vue'

import App from './App.vue'
import InfoBox from './components/InfoBox.vue'

const app = createApp(App)
app.component('info-box', InfoBox)
app.mount('#app')
                  
http://localhost:5173/