Vue $route is not defined

后端 未结 6 1204
面向向阳花
面向向阳花 2021-01-01 09:05

I\'m learning Vue router. And I want to made programmatic navigation without using in templates file. My router and view:

 ro         


        
6条回答
  •  生来不讨喜
    2021-01-01 09:52

    For those who getting the error after adding this

    TypeError: Cannot read property '$route' of undefined

    We need to use a regular function instead of ES6 arrow functions

    data: function() {
        return {
          usertype: this.$route.params.type
        };
      },
    

    This worked for me.

提交回复
热议问题