|
|
@@ -1,11 +1,10 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
<h1>watch:ref/reactive引用数据类型中的属性</h1>
|
|
|
- <h2>我有{{ flower.num }}朵{{flower.type}}花--新的:{{ flower.aaa.b }}-- {{ flower.aaa.c }}</h2>
|
|
|
+ <h2>我有{{ flower.num }}朵{{flower.type}}花</h2>
|
|
|
<button @click="changeNum">减少数量</button>
|
|
|
<button @click="changeFlower">修改全部</button>
|
|
|
<button @click="changeType">修改品类</button>
|
|
|
- <button @click="changeC">修改C</button>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -14,10 +13,7 @@ import {ref, watch} from "vue"
|
|
|
let flower = ref({
|
|
|
type:"牡丹",
|
|
|
num: 10,
|
|
|
- aaa:{
|
|
|
- b:12,
|
|
|
- c: 90
|
|
|
- }
|
|
|
+ aaa:{}
|
|
|
});
|
|
|
function changeFlower() {
|
|
|
Object.assign(flower.value,{
|
|
|
@@ -28,9 +24,6 @@ function changeFlower() {
|
|
|
const changeNum = () => {
|
|
|
flower.value.num--;
|
|
|
}
|
|
|
-const changeC = () => {
|
|
|
- flower.value.aaa.c--;
|
|
|
-}
|
|
|
const changeType = () => {
|
|
|
flower.value.type = '丁香'
|
|
|
}
|