References of an Object that defined in data-option will be changed
Version
3.0.0
Reproduction link
https://codepen.io/laineus/pen/eYZXmWZ
Steps to reproduce
const MASTER_DATA = {}
export default {
data () {
return {
MASTER_DATA // Because I want to use the Data in template
}
},
computed: {
sameAsOriginal () {
// Vue2 returns true
// Vue3 returns false
return MASTER_DATA === this.MASTER_DATA
}
}
}
What is expected?
Vue.js 2.x: An Object defined in data-option supposed to be same references as original Object.
What is actually happening?
Vue 3: The references will not be same as original.
I am not sure if this is correct behavior in Vue 3, but I couldn't find about that in the doc . Thank you.
this.MASTER_DATA
is a proxy, please use toRaw
for example,
return MASTER_DATA === toRaw(this.MASTER_DATA)