Nuxt.js: How to prevent nuxt-link jump to another page?

Created on 17 Jan 2019  路  1Comment  路  Source: nuxt/nuxt.js

I want to use the tag nuxt-link to display some A tag with attribute href.But one of them need be authorized before jump to another page,maybe show a login dialog.
How can I do it?
I tried the solution below but it didn't work

template:

<nuxt-link :to="{name: 'developer-manage'}" @click.native="checkLogin($event)">test</nuxt-link>

script:

checkLogin (e) {
  e.preventDefault()
},

Though,I solved the problem with this way:

<a :href="$router.resolve({name: 'developer-manage'}).href" @click="checkLogin($event)">test</a>

I hope nuxt-link can provide a better way to do that

This question is available on Nuxt community (#c8491)

>All comments

This issue as been imported as question since it does not respect nuxt.js issue template. Only bug reports and feature requests stays open to reduce maintainers workload.
If your issue is not a question, please mention the repo admin or moderator to change its type and it will be re-opened automatically.
Your question is available at https://cmty.app/nuxt/nuxt.js/issues/c8491.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pi0 picture pi0  路  58Comments

RDMStreet picture RDMStreet  路  56Comments

renatomattos2912 picture renatomattos2912  路  47Comments

clarkdo picture clarkdo  路  117Comments

acidjazz picture acidjazz  路  73Comments