App.vue 453 B

1234567891011121314151617181920212223242526272829
  1. <template>
  2. <h2>父级组件</h2>
  3. <h1>msg: {{ msg }}</h1>
  4. <button @click="msg += '==='">更新数据</button>
  5. <hr>
  6. <Child :msg = "msg"></Child>
  7. </template>
  8. <script lang="ts">
  9. import { defineComponent,ref } from 'vue'
  10. import Child from "./components/Child.vue"
  11. export default defineComponent({
  12. setup () {
  13. const msg = ref('在干嘛')
  14. return {
  15. msg
  16. }
  17. },
  18. components: {
  19. Child
  20. }
  21. })
  22. </script>
  23. <style scoped>
  24. </style>