parent
2030130e51
commit
587685ac8e
6 changed files with 55 additions and 53 deletions
@ -0,0 +1,35 @@ |
||||
<template> |
||||
<div class="app"> |
||||
<h3>我是app组件(祖)</h3> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import {reactive, ref, toRefs, provide, readonly, isReactive, isRef, isReadonly, isProxy} from "vue"; |
||||
|
||||
export default { |
||||
name: 'App', |
||||
setup() { |
||||
let car = reactive({ |
||||
name:'奔驰', |
||||
price: '40W' |
||||
}) |
||||
let car2 = readonly(car) |
||||
let sum = ref(0) |
||||
|
||||
console.log(isRef(sum)) |
||||
console.log(isReactive(car)) |
||||
console.log(isReadonly(car2)) |
||||
console.log(isProxy(car)) |
||||
|
||||
return {...toRefs(car)} |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<style> |
||||
.app{ |
||||
background-color: gray; |
||||
padding: 10px; |
||||
} |
||||
</style> |
After Width: | Height: | Size: 6.7 KiB |
@ -0,0 +1,10 @@ |
||||
// 引入的不再是Vue构造函数, 引入的是一个名为createApp的工厂函数
|
||||
import { createApp } from 'vue' |
||||
import App from './App.vue' |
||||
|
||||
// createApp(App).mount('#app')
|
||||
|
||||
// 创建应用实例对象
|
||||
const app = createApp(App) |
||||
console.log('@@@',app) |
||||
app.mount('#app') |
@ -1,21 +0,0 @@ |
||||
<template> |
||||
<div class="child"> |
||||
<h3>我是child组件(子)</h3> |
||||
<son/> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import son from "@/components/Son.vue"; |
||||
export default { |
||||
name: "Child", |
||||
components:{son} |
||||
} |
||||
</script> |
||||
|
||||
<style> |
||||
.child{ |
||||
background-color: skyblue; |
||||
padding: 10px; |
||||
} |
||||
</style> |
@ -1,26 +0,0 @@ |
||||
<template> |
||||
<div class="son"> |
||||
<h3>我是son组件(孙){{car.name}}-{{car.price}}</h3> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import {inject} from "vue"; |
||||
|
||||
export default { |
||||
name: "Son", |
||||
setup() { |
||||
let car = inject('car') |
||||
console.log('---son---', car) |
||||
|
||||
return {car} |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<style scoped> |
||||
.son{ |
||||
background-color: orange; |
||||
padding: 10px; |
||||
} |
||||
</style> |
Loading…
Reference in new issue