|
|
@@ -0,0 +1,31 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <hr />
|
|
|
+ <hr />
|
|
|
+ <h1>Demo4</h1>
|
|
|
+ <h3>我叫{{ obj.name }},今年{{ obj.age }}</h3>
|
|
|
+ <button @click="changeName">修改名字</button>
|
|
|
+ <button @click="changePerson">修改整体</button>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script lang="ts" setup>
|
|
|
+import {ref,reactive} from "vue"
|
|
|
+let obj = ref({
|
|
|
+ name:'图图',
|
|
|
+ age:18
|
|
|
+})
|
|
|
+console.log(obj,'obj');
|
|
|
+function changeName() {
|
|
|
+ obj.value.name = '哪吒';
|
|
|
+}
|
|
|
+function changePerson() {
|
|
|
+ obj.value = {
|
|
|
+ name: '哪吒',
|
|
|
+ age: 20
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+</style>
|