You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
545 B

2 years ago
<template>
2 years ago
<div class="app">
<h3>我是app组件{{name}}-{{price}}</h3>
<child/>
</div>
2 years ago
</template>
<script>
2 years ago
import child from "@/components/Child.vue";
import {reactive, toRefs, provide} from "vue";
2 years ago
2 years ago
export default {
name: 'App',
2 years ago
components:{child},
setup() {
2 years ago
let car = reactive({
name:'奔驰',
price: '40W'
})
provide('car', car) //给自己的后代组件传递数据
return {...toRefs(car)}
}
2 years ago
}
</script>
2 years ago
<style>
.app{
background-color: gray;
padding: 10px;
}
</style>