0.0.1 • Published 5 years ago
vue-jumpto v0.0.1
简单的 vue-router 跳转功能插件
安装
npm i vue-jumpto
使用
多页项目可能存在不同的 router,为了区分路由,这里需要使用 vue-router 的实例对象作为参数
import jumpTo from "vue-jumpto";
Vue.use(jumpTo, {
router
});
调用
example: route: [{name: "BookDetail", path: "/BookDetail/:id", props: true, component: ...}]
this.$jumpTo("/BookDetail/123?a=a1&b=b2"); // 内部跳转,传参 $router.params = {a:"a1", b: "b1", id: "123"};
this.$jumpTo("http://yourdomain.com/BookDetail/123"); // 内部跳转
this.$jumpTo({name: "BookDetail", params: {a: "a2", b: "b2", id: "456"}}); // 内部跳转,传参 $router.params = {a:"a2", b: "b2", id: "456"};
this.$jumpTo({path: "/BookDetail/456", params: {a: "a2", b: "b2"}}); // 内部跳转,传参 $router.params = {a:"a2", b: "b2", id: "456"};