ckgl/node_modules/vant/es/composables/use-route.mjs
2024-12-21 13:52:42 +08:00

30 lines
480 B
JavaScript

import {
getCurrentInstance
} from "vue";
const routeProps = {
to: [String, Object],
url: String,
replace: Boolean
};
function route({
to,
url,
replace,
$router: router
}) {
if (to && router) {
router[replace ? "replace" : "push"](to);
} else if (url) {
replace ? location.replace(url) : location.href = url;
}
}
function useRoute() {
const vm = getCurrentInstance().proxy;
return () => route(vm);
}
export {
route,
routeProps,
useRoute
};