T
T
TuMko2020-08-10 16:40:13
Vue.js
TuMko, 2020-08-10 16:40:13

How to set menu link to section id in Vue JS?

Hello. There is a landing menu, the links of which lead to the desired block with page scrolling. How to correctly display links?

<ul class="menu-list">
  <li><a class="menu-list-item" href="#about">About Me</a></li>
  <li><a class="menu-list-item" href="#users">Users</a></li>
  <li><a class="menu-list-item" href="#register">Sign Up</a></li>
</ul>

If you output like this, then the links do not work:
<li><router-link class="menu-list-item" to="#about">About Me</router-link></li>

Routes are also set in router:
{
    path: '/about',
    name: 'About',
    component: () => import('../components/About.vue')
  },
  {
    path: '/users',
    name: 'Users',
    component: () => import('../components/Users.vue')
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import('../components/Register.vue')
  }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Anton, 2020-08-10
@Fragster

If it's a single page that scrolls, no router is needed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question