【问题标题】:Passing props to router link - Vue.js将道具传递给路由器链接 - Vue.js
【发布时间】:2023-03-31 05:14:03
【问题描述】:

我正在尝试为我的路由器链接名称传递道具,但它根本不起作用。我做错了什么?

按钮组件:

<template>
      <router-link :to="{ name: nextStep }" tag="button" class="button">Back</router-link>
      <router-link :to="{ name: previousStep }" tag="button" class="button">Next</router-link>
</template>
<script>
    export default {
        props: {
            nextStep: {
                type: String,
                default: null,
            },
            previousStep: {
                type: String,
                default: null
            }
        },
     
    }
</script>

当我使用组件时

  <Buttons :nextStep="Firststep" :previousStep="Secondstep" />

和我的路由器 js 确保名称正确

{
    path: "/firststep",
    name: "Firststep",
    component: FirstStep
  },
  {
    path: "/secondstep",
    name: "Secondstep",
    component: SecondStep
  },

【问题讨论】:

    标签: javascript vue.js vuejs2


    【解决方案1】:

    尝试移除绑定标志:

    <Buttons nextStep="Firststep" previousStep="Secondstep" />
    

    如果你使用绑定符号,值应该被定义为属性。

    【讨论】:

      猜你喜欢
      • 2021-04-12
      • 2023-04-03
      • 2019-03-23
      • 1970-01-01
      • 2020-01-11
      • 1970-01-01
      • 2021-06-27
      • 1970-01-01
      • 2021-05-30
      相关资源
      最近更新 更多