MCPcopy Index your code
hub / github.com/keepfool/vue-tutorials / canReuse

Function canReuse

06.Router/basic/js/vue-router.js:1044–1059  ·  view source on GitHub ↗

* Determine the reusability of an existing router view. * * @param {Directive} view * @param {Object} handler * @param {Transition} transition

(view, handler, transition)

Source from the content-addressed store, hash-verified

1042 */
1043
1044 function canReuse(view, handler, transition) {
1045 var component = view.childVM;
1046 if (!component || !handler) {
1047 return false;
1048 }
1049 // important: check view.Component here because it may
1050 // have been changed in activate hook
1051 if (view.Component !== handler.component) {
1052 return false;
1053 }
1054 var canReuseFn = getRouteConfig(component, 'canReuse');
1055 return typeof canReuseFn === 'boolean' ? canReuseFn : canReuseFn ? canReuseFn.call(component, {
1056 to: transition.to,
1057 from: transition.from
1058 }) : true; // defaults to true
1059 }
1060
1061 /**
1062 * Check if a component can deactivate.

Callers 1

vue-router.jsFile · 0.85

Calls 1

getRouteConfigFunction · 0.85

Tested by

no test coverage detected