Passing props with programmatic navigation Vue.js

前端 未结 3 781
失恋的感觉
失恋的感觉 2020-12-05 01:59

I have a Vue component that has a prop named \'title\' e.g:



        
3条回答
  •  半阙折子戏
    2020-12-05 02:51

    Use params.

    this.$router.push({ name: 'foo', params: {title: 'test title' }})
    

    Note: You have to specify name. This does not work if you call this.$router.push using path.

    And set the route to accept params as props.

    {path: "/foo", name:"foo", component: FooComponent,  props: true}
    

    props: true is documented here.

提交回复
热议问题