S
S
Synakten2017-10-22 21:41:36
Vue.js
Synakten, 2017-10-22 21:41:36

How to make anchors in Vue js?

Good evening, I ran into the problem of implementing anchors, I previously did this on Jquery, but then there was a need to implement something similar on Vue js, and so, there is a code, well, let's say sections to which, for example, you need to move by id, (similar to jquery) , the question is how to refer to each element separately in order to place anchors or is it done in Vue somehow differently?

<ul>
        <li v-for="nav in navs" :key="nav.id">{{ nav }}</li>
      </ul>

 navs: [
        'item1',
        'item2',
        'item3',
        'item4',
        'item5'
      ]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2017-10-22
@Synakten

data: () => ({
  items: [ '...', '...', ... ],
}),

<a v-for="(n, i) in items" :href="`#item_${i}`">{{ n }}</a>
<ul>
  <li v-for="(n, i) in items" :id="`item_${i}`">{{ n }}</li>
</ul>

So will it be ok ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question