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/2021-01-18 basics-05-using-.../app.js

48 lines
1.1 KiB
JavaScript

const app = Vue.createApp({
data() {
return {
counter: 0,
name: "",
lastName: "",
// fullName: "",
vueUrl: "https://vueproject.com",
};
},
watch: {
counter(value) {
if (value > 50) {
const that = this;
setTimeout(function () {
that.counter = 0;
}, 2000);
}
},
},
computed: {
fullName() {
if (this.name === "" || this.lastName === "") {
return "";
}
return this.name + " " + this.lastName;
},
},
methods: {
setName(event) {
this.name = event.target.value;
},
add(num) {
this.counter = this.counter + num;
},
reduce(num) {
this.counter = this.counter - num;
// this.counter--;
},
resetInput() {
this.name = "";
this.lastName = "";
},
},
});
app.mount("#events");