From bc69656d06f33e02aa8738f07ed78e33570e82da Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Mon, 18 Jan 2021 21:34:43 +0100 Subject: [PATCH] add a real example for watchers --- .../app.js | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/basics-05-using-the-native-event-object/app.js b/basics-05-using-the-native-event-object/app.js index f95ae19..2b0e2c7 100644 --- a/basics-05-using-the-native-event-object/app.js +++ b/basics-05-using-the-native-event-object/app.js @@ -7,22 +7,16 @@ const app = Vue.createApp({ // fullName: "", }; }, - // watch: { - // name(value) { - // if (value === "") { - // this.fullName = ""; - // } else { - // this.fullName = value + " " + this.lastName; - // } - // }, - // lastName(value) { - // if (value === "") { - // this.fullName = ""; - // } else { - // this.fullName = this.name + " " + value; - // } - // }, - // }, + watch: { + counter(value) { + if (value > 50) { + const that = this; + setTimeout(function () { + that.counter = 0; + }, 2000); + } + }, + }, computed: { fullName() { if (this.name === "" || this.lastName === "") {