How to use the watch function from vue
Find comprehensive JavaScript vue.watch code examples handpicked from public code repositorys.
GitHub: LeFE-1/LeFE
79 80 81 82 83 84 85 86 87 88
style.msTransform = transform; style.webkitTransform = transform; return style; }; const barStyle = vue.ref(getBarStyle()); vue.watch(() => props.tabs, () => { vue.nextTick(() => { barStyle.value = getBarStyle(); }); });
3
8
3
+ 3 other calls in file
255 256 257 258 259 260 261 262 263 264
this.setAutomaticClose(); this.commit('isOpen', false); this.buildAllOptions(true); this.buildSelectedOptions(); }, { deep: true }); vue.watch(() => [this.listOptions, this.elementOptions], () => { /* TODO: transform allOptions as a computed properties and this * watcher become useless */ this.buildAllOptions(true); }, { deep: true });
1
7
6
+ 242 other calls in file
GitHub: hacfins/vue3-multi-page
106 107 108 109 110 111 112 113 114 115
states.visible = regexp.test(currentLabel.value) || props.created; if (!states.visible) { select.filteredOptionsCount--; } }; vue.watch(() => currentLabel.value, () => { if (!props.created && !select.props.remote) select.setSelected(); }); vue.watch(() => props.value, (val, oldVal) => {
1
2
1
+ 5 other calls in file
GitHub: hacfins/vue3-multi-page
195 196 197 198 199 200 201 202 203 204
} yield vue.nextTick(); initData.dragging && displayTooltip(); tooltip.value.updatePopper(); }); vue.watch(() => initData.dragging, val => { updateDragging(val); }); return { tooltip,
1
2
1
GitHub: hacfins/vue3-multi-page
29 30 31 32 33 34 35 36 37 38
const lineStyle = vue.ref({}); const internalStatus = vue.ref(''); const parent = vue.inject('ElSteps'); const currentInstance = vue.getCurrentInstance(); vue.onMounted(() => { vue.watch([() => parent.props.active, () => parent.props.processStatus, () => parent.props.finishStatus], ([active]) => { updateStatus(active); }, { immediate: true }); }); vue.onBeforeUnmount(() => {
1
2
1
GitHub: hacfins/vue3-multi-page
18 19 20 21 22 23 24 25 26 27
const isVertical = vue.ref(true); const sizeKey = vue.ref(''); const scrollKey = vue.ref(''); const translateKey = vue.ref(); const styleKey = vue.ref(''); vue.watch(() => props.direction, dir => { const _isVertical = dir === 'v'; isVertical.value = _isVertical; sizeKey.value = `client${_isVertical ? 'Height' : 'Width'}`; scrollKey.value = `scroll${_isVertical ? 'Top' : 'Left'}`;
1
2
1
+ 3 other calls in file
GitHub: hacfins/vue3-multi-page
42 43 44 45 46 47 48 49 50 51
setup(props, { slots }) { const el = vue.ref(null); const elForm = vue.inject(elFormKey); const elFormItem = vue.inject(elFormItemKey); const computedWidth = vue.ref(0); vue.watch(computedWidth, (val, oldVal) => { if (props.updateAll) { elForm.registerLabelWidth(val, oldVal); elFormItem.updateComputedLabelWidth(val); }
1
2
1
+ 5 other calls in file
98 99 100 101 102 103 104 105 106 107
_vue.onMounted(() => { _changeSelect(); }); _vue.watch(() => route.name, _changeSelect); _vue.watch(() => collapsed.value, newCollapsed => { if (!newCollapsed) { const matched = [..._vue.toRaw(route.meta.breadcrumb || [])];
1
1
4
+ 7 other calls in file
318 319 320 321 322 323 324 325 326 327
return { gap: convertToUnit(props.tabGap), }; }); // -------------------------------------------------- Watch // vue.watch(props, () => { if (props.theme) { useTheme.value = props.theme; loadTheme(); }
0
1
1
GitHub: xonar21/test23
1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108
var this$1$1 = this; if ((process.env.NODE_ENV !== 'production')) { assert(typeof getter === 'function', "store.watch only accepts a function."); } return vue.watch(function () { return getter(this$1$1.state, this$1$1.getters); }, cb, Object.assign({}, options)) }; Store.prototype.replaceState = function replaceState (state) { var this$1$1 = this;
0
0
1
+ 43 other calls in file
341 342 343 344 345 346 347 348 349 350 351
) } } function enableStrictMode (store) { vue.watch(function () { return store._state.data }, function () { if ((process.env.NODE_ENV !== 'production')) { assert(store._committing, 'do not mutate vuex store state outside mutation handlers.') } }, { deep: true, flush: 'sync' })
0
0
1
+ 7 other calls in file
GitHub: csii-cli/vue-template
86 87 88 89 90 91 92 93 94 95
element.value.style.visibility = '' } TinyMCE_1.getTinymce().init(finalInit) mounting = false } vue_1.watch(disabled, function (disable) { if (vueEditor !== null) { vueEditor.setMode(disable ? 'readonly' : 'design') } })
0
0
1
GitHub: csii-cli/vue-template
108 109 110 111 112 113 114 115 116 117
} exports.bindHandlers = bindHandlers var bindModelHandlers = function (props, ctx, editor, modelValue) { var modelEvents = props.modelEvents ? props.modelEvents : null var normalizedEvents = Array.isArray(modelEvents) ? modelEvents.join(' ') : modelEvents vue_1.watch(modelValue, function (val, prevVal) { if ( editor && typeof val === 'string' && val !== prevVal &&
0
0
1
2247 2248 2249 2250 2251 2252 2253 2254 2255 2256
vue.provide(matchedRouteKey, matchedRouteRef); vue.provide(routerViewLocationKey, routeToDisplay); const viewRef = vue.ref(); // watch at the same time the component instance, the route record we are // rendering, and the name vue.watch(() => [viewRef.value, matchedRouteRef.value, props.name], ([instance, to, name], [oldInstance, from, oldName]) => { // copy reused instances if (to) { // this will update the instance for new instances as well as reused // instances when navigating to a new route
0
0
1
+ 23 other calls in file
742 743 744 745 746 747 748 749 750 751
} if (!manager) { throw new Error('No manager or current instance'); } if (vue.isProxy(source)) { vue.watch(source, (newSource, oldSource) => { applyDifference(metaProxy.meta, newSource, oldSource); }); source = source.value; }
0
0
1
+ 3 other calls in file
vue.createElementBlock is the most popular function in vue (2388 examples)