Skip to content

Commit a3eff13

Browse files
ffxsamsdras
authored andcommitted
Showing all possible params of watch() (#1380)
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!
1 parent 524a4b5 commit a3eff13

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: src/v2/guide/computed.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ var watchExampleVM = new Vue({
213213
},
214214
watch: {
215215
// whenever question changes, this function will run
216-
question: function (newQuestion) {
216+
question: function (newQuestion, oldQuestion) {
217217
this.answer = 'Waiting for you to stop typing...'
218218
this.getAnswer()
219219
}
@@ -271,7 +271,7 @@ var watchExampleVM = new Vue({
271271
answer: 'I cannot give you an answer until you ask a question!'
272272
},
273273
watch: {
274-
question: function (newQuestion) {
274+
question: function (newQuestion, oldQuestion) {
275275
this.answer = 'Waiting for you to stop typing...'
276276
this.getAnswer()
277277
}

0 commit comments

Comments
 (0)