Nuxt.js: How do we v-on:click nuxt-link?

Created on 5 Oct 2017  路  4Comments  路  Source: nuxt/nuxt.js

How do we v-on:click nuxt-link?

I've been trying to toggle a click on a nuxt-link but seems like nothing is working...

This question is available on Nuxt.js community (#c1602)
question

Most helpful comment

Hi @rlam3

Same as router-link, you need to use v-on:click.native (https://github.com/vuejs/vue-router/issues/800)

All 4 comments

Hi @rlam3

Same as router-link, you need to use v-on:click.native (https://github.com/vuejs/vue-router/issues/800)

@Atinux Seems like I had to do the following:

<template>

  <header>
    <nav>
      <input type="checkbox" id="nav" class="hidden"/>
      <label for="nav" class="nav-open"><i></i><i></i><i></i></label>
      <div class="nav-container">
        <ul>
          <li @click="toggleMenu" ><a href="#"><i class="fa fa-phone-square fa-1x"></i> 847.228.7733</a></li>
          <li @click="toggleMenu" ><nuxt-link to="/">Home</nuxt-link></li>
          <li @click="toggleMenu" ><nuxt-link to="/about">About</nuxt-link></li>
          <li @click="toggleMenu" ><nuxt-link to="/menu">Menu</nuxt-link></li>
          <li @click="toggleMenu" ><nuxt-link to="/orderOnline">Order Online</nuxt-link></li>
        </ul>
      </div>
    </nav>
  </header>

</template>


Instead of:


<template>

  <header>
    <nav>
      <input type="checkbox" id="nav" class="hidden"/>
      <label for="nav" class="nav-open"><i></i><i></i><i></i></label>
      <div class="nav-container">
        <ul>
          <li  ><a href="#" @click="toggleMenu" ><i class="fa fa-phone-square fa-1x"></i> 847.228.7733</a></li>
          <li  ><nuxt-link  @click="toggleMenu" to="/">Home</nuxt-link></li>
          <li  ><nuxt-link  @click="toggleMenu" to="/about">About</nuxt-link></li>
          <li  ><nuxt-link  @click="toggleMenu" to="/menu">Menu</nuxt-link></li>
          <li  ><nuxt-link  @click="toggleMenu" to="/orderOnline">Order Online</nuxt-link></li>
        </ul>
      </div>
    </nav>
  </header>

</template>


For my nav bar to work properly in ....
I created a repo for this....
https://github.com/rlam3/nuxt-header-bug

@click.native="handler" in the nuxt-link works for me

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bimohxh picture bimohxh  路  3Comments

gary149 picture gary149  路  3Comments

vadimsg picture vadimsg  路  3Comments

surmon-china picture surmon-china  路  3Comments

danieloprado picture danieloprado  路  3Comments