Closed
Description
Version
3.2.33
Reproduction link
Steps to reproduce
- npm init vite@latest : create a new project (or npm init vue@latest : select vue ts)
- copy the playground App.vue to the project's App.vue
- run it !
App.vue
obj:{{ obj }}
reactiveObj:{{ reactiveObj }}
reactiveObj1:{{ reactiveObj1 }}
修改obj
修改reactive
修改reactive1
<script setup lang="ts">
import { reactive, ref, toRefs } from "vue";
import { defineComponent } from "@vue/runtime-core";
let obj = { value: 0 };
let obj1 = { value: 0 };
let reactiveObj = reactive<{ value: number }>(obj);
const reactiveObj1 = reactive<{ value: number }>(obj);
console.log("-------------------------------------");
console.log(obj === reactiveObj); // false
console.log(reactiveObj === reactiveObj1); // true
console.log(obj);
console.log(reactiveObj);
const addObj = (): void => {
obj.value += 1;
console.log(obj);
console.log("----" + reactiveObj);
};
const addRef = (): void => {
reactiveObj.value += 1;
console.log(obj);
console.log("0000");
console.log(reactiveObj);
obj = { value: 1000 };
};
function addRef1(): void {
reactiveObj1.value += 1;
console.log("1111:" + reactiveObj1.value);
reactiveObj = { value: 1000 };
}
</script>
What is expected?
the result is not the same with playground .
I think the result of playground is OK, but the real project is not the same with playground.
What is actually happening?
I have changed the reactive value to 1000 , but the template's result is not 1000 in the real project created by the command of quick start of document of vue3.
no
Metadata
Metadata
Assignees
Labels
No labels