javascript - 将道具传递给路由器链接 - Vue.js
问题描述
我正在尝试为我的路由器链接名称传递道具,但它根本不起作用。我究竟做错了什么?
按钮组件:
<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
},
解决方案
尝试删除绑定标志:
:
<Buttons nextStep="Firststep" previousStep="Secondstep" />
如果您使用绑定符号,则应将值定义为属性。
推荐阅读
- python - 如何在 sql 中确定用户是否可以在 la unix 权限系统中读取/写入/执行文件?
- javascript - bootstrap-select 动态切换多个属性
- laravel - Laravel 5.7 验证规则
- eclipse - Eclipse 中不可解析的父 POM
- php - PHP 不允许上传音频文件(wav、mp3 等)
- ruby-on-rails - 我的 erd.pdf 是乱码。我想解决这个问题
- java - 如何从 Firebase 数据库中的子项检索特定数据
- java - 在 javafx 中重新排列文本
- lombok - Fortify 抱怨 lombok 注释 @Data
- java - Log4j 中未生成日志文件