Skip to content

How to pass parameter to vue.js router in a method function?

I’m trying to send ‘’ as parameter to the router:

edit: function(joke) {
    this.$router.push({ '/edit/' + }); 

The relevant route is:

{path: '/edit/:id', component: editJoke, name: 'editJoke'},

However I get this in the console:

Module build failed: SyntaxError: Unexpected token

this.$router.push({ '/edit/' + }); 
  |                          ^

How can I fix this?


There’s no need for curly braces inside the push function. Your code should be like this:

this.$router.push('/edit/' +;