vue router 學習心得
import router from '@/router/index';
index.ts
const routes: Array<RouteRecordRaw> = [
{
path: '/',
name: 'home',
component: () => import('../views/Index.vue'),
meta: { requireAuth: true, title: 'sample app' }
},
取得網址: process.env.BASE_URL+router.resolve({ name: 'xxx' }).href
導向網址: router.push({ name: 'xxx', query: {p1: 123} })
網址有指定參數(e.g., path: '/xxx/:id'): router.push({ name: 'xxx', params: { id: xxx }, query: { p1: 123 } });
留言