lesson 28: computed properties

This commit is contained in:
Andreas Zweili 2021-01-18 21:14:00 +01:00
parent f7f506471f
commit c7ad6bfe14
2 changed files with 5 additions and 3 deletions

View File

@ -5,13 +5,15 @@ const app = Vue.createApp({
name: "",
};
},
methods: {
outputFullName() {
computed: {
fullName() {
if (this.name === "") {
return "";
}
return this.name + " " + "Muster";
},
},
methods: {
setName(event) {
this.name = event.target.value;
},

View File

@ -22,7 +22,7 @@
<p>Result: {{ counter }}</p>
<input type="text" v-model="name">
<button v-on:click="resetInput">Reset Input</button>
<p>Your Name: {{ outputFullName() }}</p>
<p>Your Name: {{ fullName }}</p>
</section>
</body>