当前位置:   article > 正文

vue-element-admin动态路由且传参_eleadmin传参

eleadmin传参

单个动态路由,props对象模式

  1. {
  2. path: "/turbinesId",
  3. name: "Turbines",
  4. props: { turbinesId: data.turbinesId, turbinesName: data.turbinesName, other: 'welcome'},
  5. components: () => import("../views/turbines.vue"),
  6. }

接收页面

  1. export default {
  2. name: "Turbines",
  3. props: ["turbinesId", "turbinesName", "other"],//props也可以写成对象的形式
  4. mounted() {
  5. console.log("Info", this.$props);
  6.     console.log("Info-----", this.turbinesId, this.turbinesName, this.other);
  7. },
  8. };

二、循环增加动态路由

代码如下:

  1. const addRoute = {
  2. path: '/components',
  3. component: Layout,
  4. name: 'ComponentDemo',
  5. meta: {
  6. title: '导航',
  7. icon: 'component'
  8. },
  9. children: []
  10. }
  11. for (let i = 0; i < 33; i++) {
  12. const children = {
  13. path: `tinymce/${i + 1}/menu${i + 1}`,
  14. component: () => import('@/views/components-demo/tinymce'),
  15. name: `tinymce${i + 1}`,
  16. meta: {title: `menu${i + 1}`, noCache: true},
  17. props: {turbinesId: i + 1, turbinesName: `menu${i + 1}`},
  18. }
  19. addRoute.children.push(children)
  20. }

效果就是下面这样子

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/58970
推荐阅读
相关标签
  

闽ICP备14008679号