如何通过 <router-view> 传递动态 props

S M*_*han 5 vue.js vue-router vue-component vuex

我在 vue 中有一个应用程序并注册了路由器,我需要的只是通过 .

应用程序.vue

<template>
  <v-app>
    <router-view :user="userVariable"></router-view>
  </v-app>
</template>

Run Code Online (Sandbox Code Playgroud)

路由器.js

Vue.use(Router);
export default new Router({
  mode: 'history',
  base: process.env.BASE_URL,
  routes: [
    {
      path: '/login',
      name: 'Login',
      component: Login,
      props: true,
    },
    {
      path: '/profile',
      name: 'profile',
      component: Profile,
      props: true,
    },
  ],
});
Run Code Online (Sandbox Code Playgroud)

我在启动组件时获得了道具,但在更新值时无法获得更新的道具userVariable。:(

And*_*tej 5

我创建了这个 CodeSanbox 示例,其中一切似乎都工作正常。

当您传递的变量是原始值或非原始值时,我已经尝试过这两种情况。