I am facing a problem when I try to update properties of a reactive 'global variable' (using Vue 3). When I change the name of the user, this should(?) re-render the element, but it doesn't. What am I missing here?
<div id="app">
{{ controller.user.name }}
<button @click="controller.change">Change</button>
</div>
<script src="https://unpkg.com/vue@next"></script>
<script>
var controller = {
user: {
name: 'Pete'
},
change: () => {
controller.user.name = 'Arnold'
}
}
var reactive = Vue.reactive({controller});
var app = Vue.createApp({
data() {
return reactive
}
}).mount('#app')
</script>
It does show the initial name. When one presses the button, the name value in the controller will change though (you can check that it changed in the console). Only the re-render doesn't happen.
Also tried using this.controller.user.name, but without any luck.