how to use vue-router params

后端 未结 4 1749
被撕碎了的回忆
被撕碎了的回忆 2021-02-12 08:06

I\'m new to vue now working with its router. I want to navigate to another page and I use the following code:

this.$router.push({path: \'/newLocation\', params:          


        
4条回答
  •  隐瞒了意图╮
    2021-02-12 08:44

    Isn't it generally considered an anti pattern to bind the properties to the router?

    It's a much more DRY solution to have them bind to the component it's self, which I actually believe the Vue router does. Please see: https://router.vuejs.org/en/essentials/passing-props.html for more info on the best practices here

    Can you try accepting the property in the props: [] property of your component? You can see how to do that here: https://vuejs.org/v2/guide/components.html#Props

    Please do pop up if you have any questions! Happy to help further.

提交回复
热议问题