Update the values of reactive and shallowReactive at the same time, causing the original effect of shallowReactive to be invalid. #6603
Unanswered
BobsLi
asked this question in
Help/Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
同时更新reactive和shallowReactive的值,导致shallowReactive原有作用无效, 这是什么原因导致的呢
`<script setup lang="ts">
// This starter template is using Vue 3 <script setup> SFCs
// Check out https://vuejs.org/api/sfc-script-setup.html#script-setup
import { reactive, shallowReactive } from 'vue';
let message = reactive({ li: { name: 'li' } })
let message2 = shallowReactive({ wang: { name: 'wang' } })
function changMessage() {
message.li.name = 'my name is li'
message2.wang.name = 'my name is wang'
console.log('message1', message)
console.log('message2', message2)
}
</script>
message1: {{ message.li.name }}
message2: {{ message2.wang.name }}
Beta Was this translation helpful? Give feedback.
All reactions