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