Skip to content

reactive is working not consistent with playground #5741

Closed
@asialiugf

Description

@asialiugf

Version

3.2.33

Reproduction link

sfc.vuejs.org/

Steps to reproduce

  1. npm init vite@latest : create a new project (or npm init vue@latest : select vue ts)
  2. copy the playground App.vue to the project's App.vue
  3. 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions