10 examples of 'vue watch nested property' in JavaScript

Every line of 'vue watch nested property' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
92public watchPath(path: string): void {
93 if (!CExample.all[path]) {
94 this.existed = false;
95
96 return;
97 }
98
99 this.existed = true;
100
101 const has: Record = {};
102 const src: Record = {};
103
104 defaultTypes.forEach(ext => {
105 has[ext] = false;
106 src[ext] = '';
107 });
108 CExample.all[path].forEach(ext => {
109 has[ext] = true;
110 src[ext] = '';
111 });
112
113 this.extensions = [...new Set([...defaultTypes, ...CExample.all[path]])];
114 this.has = has;
115 this.src = src;
116
117 this.loadSourceCode();
118}
116function watchProps (watchDepth, scope, watchExpressions, listener){
117 var supportsWatchCollection = angular.isFunction(scope.$watchCollection);
118 var supportsWatchGroup = angular.isFunction(scope.$watchGroup);
119
120 var watchGroupExpressions = [];
121 watchExpressions.forEach(function(expr){
122 var actualExpr = getPropExpression(expr);
123 var exprWatchDepth = getPropWatchDepth(watchDepth, expr);
124
125 if (exprWatchDepth === 'collection' && supportsWatchCollection) {
126 scope.$watchCollection(actualExpr, listener);
127 } else if (exprWatchDepth === 'reference' && supportsWatchGroup) {
128 watchGroupExpressions.push(actualExpr);
129 } else {
130 scope.$watch(actualExpr, listener, (exprWatchDepth !== 'reference'));
131 }
132 });
133
134 if (watchGroupExpressions.length) {
135 scope.$watchGroup(watchGroupExpressions, listener);
136 }
137}
42function watcher(prop, callback, next, prev) {
43 if (this.initial) return;
44 if (this.$listeners[`update:${prop}`]) {
45 if (this.propsIsUpdating[prop]) {
46 this._watcher.active = false;
47 this.$nextTick(() => {
48 this._watcher.active = true;
49 });
50 } else {
51 this._watcher.active = true;
52 callback(next, prev);
53 }
54 this.propsIsUpdating[prop] = false;
55 } else {
56 callback(next, prev);
57 }
58}
25function initWatch(vm) {
26 var watch = vm.$options.watch;
27 if (watch) {
28 for (const key in watch) {
29 const handler = watch[key]
30 if (Array.isArray(handler)) {
31 for (let i = 0; i < handler.length; i++) {
32 createWatcher(vm, key, handler[i])
33 }
34 } else {
35 createWatcher(vm, key, handler)
36 }
37 }
38 }
39}
33private w0() {
34 Schedule.multiSelect = this.display.multiSelect;
35 this.schedule.recomputeAll(false, 100);
36}
259anotherMethod() {
260 method2 = 2
261}
157function initWatch (vm, watch) {
158 for (const key in watch) {
159 const handler = watch[key]
160 if (Array.isArray(handler)) {
161 // 为什么这里会是数组
162 // Sub = Vue.extend({ watch: {a:funcA }}), subvm = new Sub({ watch: {a:funcB })
163 // 最终subvm的options.watch = { "a": [funcA, funcB] }
164 for (let i = 0; i < handler.length; i++) {
165 createWatcher(vm, key, handler[i])
166 }
167 } else {
168 createWatcher(vm, key, handler)
169 }
170 }
171}
181initWatch() {
182 for (const key in this.watch) {
183 new Watcher(this, key, this.watch[key])
184 }
185}
20private onChildChanged(to: Route, from: Route) {
21 if (to.params['stack-key-dir'] === 'forward') {
22 this.transitionName = 'forward';
23 } else {
24 this.transitionName = 'back';
25 }
26}
510registerComplexWatchers: function registerComplexWatchers() {
511 var _this4 = this;
512
513 var props = ['fixed'];
514 var aliases = {
515 realWidth: 'width',
516 realMinWidth: 'minWidth'
517 };
518 var allAliases = props.reduce(function (prev, cur) {
519 prev[cur] = cur;
520 return prev;
521 }, aliases);
522
523 Object.keys(allAliases).forEach(function (key) {
524 var columnKey = aliases[key];
525
526 _this4.$watch(key, function (newVal) {
527 _this4.columnConfig[columnKey] = newVal;
528 var updateColumns = columnKey === 'fixed';
529 _this4.owner.store.scheduleLayout(updateColumns);
530 });
531 });
532}

Related snippets