proxy not contain a compoennt value on the prod env(dev is ok)
Vue version
3.2.37
Link to minimal reproduction
Steps to reproduce
common.js :
import { getCurrentInstance } from 'vue'
export function useChild() {
const { proxy } = getCurrentInstance()
function fun(name) {
console.log('has msg ?', 'msg' in proxy)
proxy.msg += name
}
return {
fun
}
}
app.vue :
<script setup>
import { ref, getCurrentInstance } from 'vue'
import child1 from './child1.vue'
const msg = ref('Hello World!')
</script>
<template>
<h1>{{ msg }}</h1>
<input v-model="msg">
<child1></child1>
</template>
child1.vue :
<script setup>
import { ref, onMounted } from 'vue'
import { useChild } from './common.js'
import child2 from './child2.vue'
const { fun } = useChild()
const msg = ref('This is:')
onMounted(() => fun('child1'))
</script>
<template>
<h1>{{ msg }}</h1>
<child2/>
</template>
What is expected?
in prod env, The proxy contain msg
What is actually happening?
in prod env, The proxy not contain msg
System Info
No response
Any additional comments?
No response
add:
//work in this case
<script lang="ts">
setup() {
// do something.....
}
</script>
// not work
<script lang="ts" setup>
</script>
This has been fixed in 3.2.45, but maybe not in the way you want it to. See:
https://github.com/vuejs/core/issues/6248 https://github.com/vuejs/core/commit/f73925d76a76ee259749b8b48cb68895f539a00f