提交 d6c645c2 编写于 作者: B big_sun_962464

Thu Jun 20 22:29:00 CST 2024 inscode

上级 79c5bd79
<script setup> <script setup>
import HelloWorld from './components/HelloWorld.vue' import {ref,reactive,shallowRef} from 'vue'
import TheWelcome from './components/TheWelcome.vue' const obj = shallowRef({
level:1,
grandFather:{
level:2,
father:{
level:3,
son:{
level:4,
grandSon:{
level:5,
name:'grandSon'
}
}
}
}
})
const count = ref(1)
const obj1 = reactive({
count
})
const books = reactive([
ref('vue3.0')
])
console.log(books[0].value)
function changeGrandFather(){
obj.value.level = 2
}
</script> </script>
<template> <template>
<header> <div>
<img alt="Vue logo" class="logo" src="./assets/logo.svg" width="125" height="125" /> {{count}}-{{obj1}}-{{books}}
<button @click="obj1.count = 2"></button>
<div class="wrapper"> <pre>{{obj}}</pre>
<HelloWorld msg="You did it!" /> <!-- {{obj}} -->
</div> <hr/>
</header> <button @click="obj={name:'obj'}">obj</button>
<button @click="obj.level++">changeGrandFather</button>
<main> <button @click="obj.grandFather.level++">changeFather</button>
<TheWelcome /> <button @click="obj.grandFather.father.level++">changeSon</button>
</main> <button @click="obj.grandFather.father.son.level++">changeGrandSon</button>
<button @click="obj.grandFather.father.son.grandSon.level++">lastLevel</button>
<button @click="obj.name='grandFather'">+grandFather</button>
<button @click="obj.grandFather.name = 'father'">+father</button>
<button @click="obj.grandFather.father.name = 'son'">+son</button>
<button @click="obj.grandFather.father.son.grandSon.age = 12">++</button>
</div>
</template> </template>
<style scoped> <style scoped>
header {
line-height: 1.5;
}
.logo {
display: block;
margin: 0 auto 2rem;
}
@media (min-width: 1024px) {
header {
display: flex;
place-items: center;
padding-right: calc(var(--section-gap) / 2);
}
.logo {
margin: 0 2rem 0 0;
}
header .wrapper {
display: flex;
place-items: flex-start;
flex-wrap: wrap;
}
}
</style> </style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册