From 792154ff5eb3dce1c67025df3fb7f5d1bbe006e2 Mon Sep 17 00:00:00 2001 From: Sirius Wang Date: Thu, 20 Jun 2019 21:57:39 +0800 Subject: [PATCH] a little dairy of sirius wang rainy day always upset me --- dairy.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 dairy.js diff --git a/dairy.js b/dairy.js new file mode 100644 index 0000000..861fe75 --- /dev/null +++ b/dairy.js @@ -0,0 +1,33 @@ +class Dairy { + constructor(date,weather,content) { + this.date = date; + this.weather = weather; + this.content = content; + this._clear = clearDairy.bind(this); + } + printDairy () { + console.log(this.date); + console.log(this.weather); + console.log(this.content); + } + addClearEvent () { + document.addEventListener('click', this._clear, false); + } + removeClearEvent () { + document.removerEventListener('click', this._clear, false); + } +} + +let date = '2019-06-20'; +let weather = 'rainy'; +let content = 'it is a rainyday,and i am so upset.' + +let newDairy = new Dairy(date,weather,content); +newDairy.printDairy(); + + +function clearDairy(dairy){ + dairy.date = ''; + dairy.weather = ''; + dairy.content = ''; +} \ No newline at end of file