Prerana
Prerana

Reputation: 568

Trigger another click event inside nuxt-link

<div>
  <nuxt-link to="/home">
    <h1>Title text</h1>
    <p>Product description</p>
    <p @click.stop="addCart()">Add to cart</p>
  </nuxt-link>
</div>

I'm not able to click my addCart function. If I click it's just redirecting to home page.

Upvotes: 1

Views: 1314

Answers (2)

I solve this by prevent event modifier in vue

@click.prevent="addCart()

or

<div>
    <nuxt-link to="/home">
        <h1>Title text</h1>
        <p>Product description</p>
        <p @click.prevent="addCart()">Add to cart</p>
    </nuxt-link>
</div>

Upvotes: 1

norbekoff
norbekoff

Reputation: 1965

This should solve your problem:

@click.prevent="addCart()"

Upvotes: 5

Related Questions