I’m trying to send ‘joke.id’ as parameter to the router:
edit: function(joke) { this.$router.push({ '/edit/' + joke.id }); }
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/' + joke.id }); | ^
How can I fix this?
Advertisement
Answer
There’s no need for curly braces inside the push
function. Your code should be like this:
this.$router.push('/edit/' + joke.id);