Your cart is currently empty!
Vue router link 动态路由 链接写法
写好的路由是(关键是/Drawing/:id那个)
export default new Router({
mode:'history',
routes: [
{ path: '/', name: 'home', component: App},
{ path: '/hello', name: 'Main', component: Hello },
{ path: '/Drawing/:id',name:'drawing',component:Drawing}
]
})
会把所有的/Drawing/1 或/Drawing/2都导向一个界面
然后对应的Drawing组件里直接用$route.params.id 就能拿到链接后的Id,
但是router-link这里比较发愁,要怎么生成一个链接
上网搜了一下, 咳咳原来直接..按js写就好 字符串 + 变量 没毛病!记得to前面的冒号
参考:https://blog.csdn.net/sangjinchao/article/details/70888259
发表回复