first
This commit is contained in:
36
node_modules/vant/es/utils/router.js
generated
vendored
Normal file
36
node_modules/vant/es/utils/router.js
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Vue Router support
|
||||
*/
|
||||
function isRedundantNavigation(err) {
|
||||
return err.name === 'NavigationDuplicated' || // compatible with vue-router@3.3
|
||||
err.message && err.message.indexOf('redundant navigation') !== -1;
|
||||
}
|
||||
|
||||
export function route(router, config) {
|
||||
var to = config.to,
|
||||
url = config.url,
|
||||
replace = config.replace;
|
||||
|
||||
if (to && router) {
|
||||
var promise = router[replace ? 'replace' : 'push'](to);
|
||||
/* istanbul ignore else */
|
||||
|
||||
if (promise && promise.catch) {
|
||||
promise.catch(function (err) {
|
||||
if (err && !isRedundantNavigation(err)) {
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (url) {
|
||||
replace ? location.replace(url) : location.href = url;
|
||||
}
|
||||
}
|
||||
export function functionalRoute(context) {
|
||||
route(context.parent && context.parent.$router, context.props);
|
||||
}
|
||||
export var routeProps = {
|
||||
url: String,
|
||||
replace: Boolean,
|
||||
to: [String, Object]
|
||||
};
|
Reference in New Issue
Block a user