小编S M*_*han的帖子

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

我在 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。:(

vue.js vue-router vue-component vuex

5
推荐指数
1
解决办法
5341
查看次数

标签 统计

vue-component ×1

vue-router ×1

vue.js ×1

vuex ×1