From e49a31edf8a7486bd8a0233e6a85cd8862ed09b2 Mon Sep 17 00:00:00 2001 From: Julien Le Coupanec Date: Fri, 1 Dec 2017 13:28:16 +0100 Subject: [PATCH] Vue: Instance Methods / Data --- frontend/vue.js | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/frontend/vue.js b/frontend/vue.js index 13f1a3e..c8870e8 100644 --- a/frontend/vue.js +++ b/frontend/vue.js @@ -389,6 +389,15 @@ new Vue({ * ******************************************************************************************* */ + + + +/* ******************************************************************************************* + * INSTANCE PROPERTIES + * https://vuejs.org/v2/api/#Instance-Properties + * ******************************************************************************************* */ + + // The data object that the Vue instance is observing. // The Vue instance proxies access to the properties on its data object. vm.$data @@ -447,22 +456,36 @@ vm.$attrs vm.$listeners -/* ******************************************************************************************* - * INSTANCE PROPERTIES - * https://vuejs.org/v2/api/#Instance-Properties - * ******************************************************************************************* */ - - - - - /* ******************************************************************************************* * INSTANCE METHODS > DATA * https://vuejs.org/v2/api/#Instance-Methods-Data * ******************************************************************************************* */ +// Watch an expression or a computed function on the Vue instance for changes. +// The callback gets called with the new value and the old value. +// The expression only accepts dot-delimited paths. +// For more complex expressions, use a function instead. +var unwatch = vm.$watch('a.b.c', function (newVal, oldVal) { + // do something +}, { + // To also detect nested value changes inside Objects, you need to pass in deep: true + // in the options argument. Note that you don’t need to do so to listen for Array mutations. + deep: true, + // Passing in immediate: true in the option will trigger the callback immediately with the + // current value of the expression: + immediate: true +}) + +// later, teardown the watcher +unwatch() + +// This is the alias of the global Vue.set. +vm.$set( target, key, value ) + +// This is the alias of the global Vue.delete. +vm.$delete( target, key ) /* *******************************************************************************************