From 033060bfbd94f5a47ea5d74999e826a6ddce8622 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 11 Jan 2018 14:36:14 -0600 Subject: [PATCH] Showing all possible params of watch() Surprised that the documentation didn't include the fact that the 2nd argument is the previous value. This can be really useful in some cases! --- src/v2/guide/computed.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/v2/guide/computed.md b/src/v2/guide/computed.md index 1fd03996d3..fdf9fdcc62 100644 --- a/src/v2/guide/computed.md +++ b/src/v2/guide/computed.md @@ -213,7 +213,7 @@ var watchExampleVM = new Vue({ }, watch: { // whenever question changes, this function will run - question: function (newQuestion) { + question: function (newQuestion, oldQuestion) { this.answer = 'Waiting for you to stop typing...' this.getAnswer() } @@ -271,7 +271,7 @@ var watchExampleVM = new Vue({ answer: 'I cannot give you an answer until you ask a question!' }, watch: { - question: function (newQuestion) { + question: function (newQuestion, oldQuestion) { this.answer = 'Waiting for you to stop typing...' this.getAnswer() }