0

Here is my code to setup the vuejs routes and pass into router:

export const routesArray = {
  routes: [
    {
      path: '/',
      name: 'Add Stash',
      component: Form
    },
    {
      path: '/log',
      name: 'Stash Log',
      component: Stitch
    },
    {
      path: '/user/register',
      name: 'Register',
      component: Register
    },
    {
      path: '/user/login',
      name: 'Log in',
      component: Login
    }
  ]
}
export default new Router(routesArray)

I'm importing this code into a Vue Component and using it to loop through the array and dynamically output the navigation like this:

<ul class="nav">
  <li v-for="item in routes">
      <a :href="item.path"> {{item.name}}</a>
  </li>

This display works like a dream, but when I click on a nav item, it goes to a broken link: http://localhost:8080/log#/

Instead of this: http://localhost:8080/#/log

I'm not sure how to get around that hash? Any ideas?

1 Answer 1

1

Use router-link instead of a.

<li v-for="item in routes">
    <router-link :to="item.path">{{item.name}}</router-link>
</li>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.