ref with an object

This commit is contained in:
Andreas Zweili 2021-07-30 15:46:49 +02:00
parent 65756e999b
commit 9dccf4982e
1 changed files with 9 additions and 4 deletions

View File

@ -1,6 +1,7 @@
<template>
<section class="container">
<h2>{{ userName }}</h2>
<h2>{{ user.name }}</h2>
<h2>{{ user.age }}</h2>
</section>
</template>
@ -9,14 +10,18 @@ import { ref } from 'vue';
export default {
setup() {
const userName = ref('Foo Bar');
const user = ref({
name: 'Foo',
age: 23
});
setTimeout(function() {
userName.value = 'baz';
user.value.name = 'baz';
user.value.age = '25';
}, 2000);
return {
userName
user
};
}
};