Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

vue-router 动态设置meta

各位大佬,有没有什么办法可以动态设置meta?

{
  path: 'product',
  component: () => import('@/views/product'),
  meta: {
    breadcrumb: '添加产品'
  }
},

我的面包屑是一个组件,根据路由里面的meta生成

编辑和添加是同一个页面,但是我想在面包屑动态设置breadcrumb,当this.$router.query.id有值时,显示编辑产品,否则添加产品


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

2020828-145957.jpg
可以换个思路,改下路由配置,新增和编辑用同一个组件,你可以配置两个路由


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...