【问题标题】:Vue js - passing props to components in vue rotuerVue js - 将道具传递给Vue路由器中的组件
【发布时间】:2018-07-02 09:54:06
【问题描述】:

我的主页中有以下内容

<info-panel type="updates"><info-panel/>

它的扩展版本存在于不同的页面上。如何在我的路由器中将相同的道具传递给它?

  path: '/infopanel',
        components: {
          default: InfoPanel,
          nav: PrimaryNav
        },
   }

【问题讨论】:

    标签: vue.js vuejs2 vue-router


    【解决方案1】:

    这种方式应该可以工作:

      path: '/infopanel',
        components: {
          default: InfoPanel,
          nav: PrimaryNav
        },
        props: { 
          default: true, 
          type: "updates" 
        }
      }
    

    这是您要达到的目标的指南:

    https://router.vuejs.org/guide/essentials/passing-props.html#passing-props-to-route-components

    【讨论】:

    • 嗨,只有当我有一个组件而不是组件对象时才通过它。
    猜你喜欢
    • 2020-04-03
    • 2019-03-23
    • 2023-04-03
    • 2018-06-20
    • 2021-11-27
    • 2020-12-04
    • 2019-12-27
    • 2021-09-11
    • 2018-02-20
    相关资源
    最近更新 更多