vue 重定向和组件传参

重定向

通过配置index.js 使得匹配到一些路径直接重定向到某一个地方

带逻辑判断跳转

带参数跳转

组件传参

布尔模式

如果 props 被设置为 true,route.params 将会被设置为组件属性。
在index.js添加props true

组件这里即可直接使用

<template>
  <div>
    <h3>User ID :{{id}}</h3>
    <router-view/>
  </div>
</template>

<script>
export default {
  name: "Users",
  props : {
    id : {
      type:Number
    }
  }
}
</script>

<style scoped>

</style>
posted @ 2021-07-26 16:05  一个经常掉线的人  阅读(66)  评论(0编辑  收藏  举报