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: "", name: "",
}; };
}, },
methods: { computed: {
outputFullName() { fullName() {
if (this.name === "") { if (this.name === "") {
return ""; return "";
} }
return this.name + " " + "Muster"; return this.name + " " + "Muster";
}, },
},
methods: {
setName(event) { setName(event) {
this.name = event.target.value; this.name = event.target.value;
}, },

View File

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