template local variable pollution
Vue version
3.2.47
Link to minimal reproduction
https://github.com/kinfuy/vue-template-bug
Steps to reproduce
<template>
<div v-show="false">
{{ text = ['1,2,3,4,5'] }}
</div>
<div>{{ text }}</div>
</template>
What is expected?
text not found
What is actually happening?
text normal operation
System Info
No response
Any additional comments?
No response
I think this isn't a bug. Vue3 is the same presentation form as Vue2.
https://stackblitz.com/edit/vue2-vue-cli-d2v8f6?file=src/App.vue
I think this isn't a bug too.
{{ text = ['1,2,3,4,5'] }}
is compiled by the compiler into code text.value = ['1,2,3,4,5']
, and rendered run when. And v-show
just controls the display property. text.value = ['1,2,3,4,5']
will still execute, which I think is expected
I think this kind of feeling is a little dark magic. Declare variables in the template, and they are valid in the entire template. This vue2 has the same effect. I'm not sure if it needs to be modified @AlexVagrant @baiwusanyu-c