lesson 28: computed properties
This commit is contained in:
parent
f7f506471f
commit
c7ad6bfe14
|
@ -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;
|
||||||
},
|
},
|
||||||
|
|
|
@ -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>
|
||||||
|
|
||||||
|
|
Reference in New Issue