D
D
Devero972021-02-06 20:44:57
Vue.js
Devero97, 2021-02-06 20:44:57

How to jump to a page to a specific tag?

I am using nuxt-link. When I go to the next router - domen/post/ychim-yroki#comments, I want to get to the page with the post Learning lessons, but get to the block with comments. When I navigate, I land on this post, but stay at the top of the page. Is there such a possibility at all?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Yarkov, 2021-02-06
@yarkov Vue.js

<a name="comments"></a> <!-- Вот к этому тегу страница прокрутится, если в хэше урла будет такое же имя -->
<div>
  Блок с комментариями
</div>

Well, you should always look for answers in the documentation .
scrollBehavior (to, from, savedPosition) {
  if (to.hash) {
    return {
      selector: to.hash
      // , offset: { x: 0, y: 10 }
    }
  }
}

A
Alex, 2021-02-06
@Kozack Vue.js

https://htmlacademy.ru/courses/305/run/5

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question