Jay Peg
Jay Peg

Reputation: 25

How to create a dynamic anchor link in nuxt.js?

I'm building a nuxt onepager that is feeded with content from the Wordpress Rest Api.

I'm already getting the Wordpress menu structure and every menu item is stored in {{ item.title }}. To scroll later to the requested div with it's id {{ item.title }} i want to complete the {{ item.title }} with a #.

My idea so far is: <nuxt-link to="'#'{item.title}'" exact class="nav-link">{{ item.title }}</nuxt-link>

Upvotes: 1

Views: 2381

Answers (1)

Boussadjra Brahim
Boussadjra Brahim

Reputation: 1

You could bind it as follows :

<nuxt-link :to="'#'+item.title" exact class="nav-link">{{ item.title }}</nuxt-link>

Upvotes: 2

Related Questions