Subscribe on changes!

upgrade V2.7 to V3.3

avatar
Dec 7th 2023

Vue version

Vue 3.3

Link to minimal reproduction

https://www.zhihu.com/question/491344944

Steps to reproduce

in Vue 2.7 it works:

<div v-if="loading">
<div>

 const state=reactive({
  loading:false
})

defineExpose({
  ...toRefs(state)
}

now I hope upgrade Vue 3.3,I find template can not reslove 'loading'

I know it works if I use toRefs like this :

const { loading} = toRefs(state)

But it has about more than 200 pages in my project ,will I change it one by one like this?

What is expected?

defineExpose ({ }...toRefs(state)) I hope the code still work in Vue 3.3 or other way I change less code

What is actually happening?

If any way I upgrade with less code?

System Info

No response

Any additional comments?

No response

avatar
Dec 7th 2023

This just happens to work in Vue 2 (unfortunately), but is not expected behavior in Vue 3.

Either refactor to use destructuring, or prefix your template expressions with state..