Billal BEGUERADJ
Billal BEGUERADJ

Reputation: 22754

Nuxt.js and anchors

How to deal with anchors (within the same page) in Nuxt.js ?

Problem is the URL stays always on the base localhost:3000/ I want to have anchors displayed on the URL too: localhost:3000/#anchor1, localhost:3000/#anchor2, localhost:3000/#anchor3 … etc.

It seems <nuxt-link :to=(/#anchorid)> Inner link </nuxt-link> does not do the job.

How to achieve this functionality?

Upvotes: 1

Views: 2194

Answers (1)

Madhuri kulkarni
Madhuri kulkarni

Reputation: 95

If using locales

<nuxt-link 
  :to="localePath({ name: 'index', hash: '#anchor1'})" 
  v-text="Anchor 1" 
  alt="Anchor 1">
</nuxt-link>

Else

<nuxt-link to="/anchor1" v-text="Anchor 1" />

Upvotes: 1

Related Questions