Error using v-go-back

  • Hello !! I am trying to use the new Directive “v-go-back”, but i am getting the following error:
    [Vue warn]: Invalid expression. Generated function body: /

    I am using that on my menu like that:
    <quasar-drawer-link v-go-back="/" icon=“exit_to_app”>

    My routes:
    let routes = {
    // Not found
    ‘*’: {
    component: load(‘error404’)

    // Index
    ‘/’: {
    name: ‘index’,
    component: load(‘index’)

    ‘/login’: {
    name: ‘login’,
    component: load(‘auth/login’)

    ‘/register’: {
    name: ‘register’,
    component: load(‘auth/register’)

    Any idea ?

  • Admin

    Surround / with simple quotes. You should use it like this: v-go-back="’/’"
    Please note double quote, quote, /, quote, double quote. Thjs is due to Vue inner workings.

  • thanks @rstoenescu !! It works now ! Maybe we must update the documentation too about that .?

  • Admin

    Yeah, just use it like you would with v-link.

  • Hi @rstoenescu
    I have some issued with v-link/v-go-back directive. Please guide me some thing about them 🙂
    How can I use v-go-back to back 1 step in the window histories ? We can do some action to call async to logout with v-go-back or not ? The v-link can apply active class for button or not ?

  • Admin

    v-link applies router-link-active CSS class when it’s appropriate.
    v-go-back can only be used with a route. Cant specify number of steps and can’t call an async function when being triggered. Because this is a convenience directive. If you want a specific behavior you can just add @click event to your element and trigger your async function along window.history.go(-1).

  • @rstoenescu
    v-go-back directive is the same as $router.back() or different? I don’t know what is different between them?

Log in to reply