This repository has been archived on 2021-09-06. You can view files and clone it, but cannot push or open issues or pull requests.
vuejs_course/basics-assignment-4-problem/app.js
Andreas Zweili 6108d09c4c computed properties are as the name says computed
since the :class parameter awaits true and false I can compute those
directly inside the computed properties.
2021-01-18 23:35:06 +01:00

29 lines
646 B
JavaScript

"use strict";
const app = Vue.createApp({
data() {
return {
inputClass: "",
paragraphVisible: true,
inputColor: "",
};
},
computed: {
classFromUserInput() {
return {
user1: this.inputClass === "user1",
user2: this.inputClass === "user2",
visible: this.paragraphVisible,
hidden: !this.paragraphVisible,
};
},
},
methods: {
toggleParagraphVisibility() {
this.paragraphVisible = !this.paragraphVisible;
},
},
});
app.mount("#assignment");