Vue-material: [Question] Using vue-router definition in <md-list-item>

Created on 13 Dec 2016  路  6Comments  路  Source: vuematerial/vue-material

I have installed this awesome vue-material in my vuejs project, also I use vue-router to manage app routing. In component list I want use <router-link> as <md-list-item> instead of using url properties in <md-list-item url="URL">.

this is posible and how can I implement it?

question

Most helpful comment

@rslhdyt I am not sure if I understood from your question, but is it something like this you need?

        <md-list-item>
          <router-link exact to="/changelog">
            <md-icon class="md-primary">person</md-icon>
            <span>My Profile</span>
          </router-link>
        </md-list-item>

All 6 comments

To my knowledge it is not possible at the moment. As a workaround I use Javascript routing like this:

<md-button @click="onSignIn">Sign In</md-button>

methods: {
  onSignIn() {
    this.$router.push({name: 'login'}); 
  }
}

@rslhdyt I am not sure if I understood from your question, but is it something like this you need?

        <md-list-item>
          <router-link exact to="/changelog">
            <md-icon class="md-primary">person</md-icon>
            <span>My Profile</span>
          </router-link>
        </md-list-item>

The @Sarpedion solution is the way to achieve that. The Vue Material documentation use this approach.

Thanks!

@Sarpedion actualy I've tried like your example. but more simply

<md-list-item> <router-link exact to="/changelog">My Profile</router-link> </md-list-item>
but unfortunately it is not working.

I'll use @fusion44 solutions, because I need a callback after page is reloaded.

Thank You All

The @fusion44 method works, but dont let users to open the link in another tab.
I'm using this in the documentation Website:

<md-list-item>
  <router-link exact to="/">Introduction</router-link>
</md-list-item>

The @fusion44 method works, but dont let users to open the link in another tab.

Noted! @marcosmoura

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lovepluskaka picture lovepluskaka  路  3Comments

markus-s24 picture markus-s24  路  3Comments

korylprince picture korylprince  路  3Comments

lee-frank picture lee-frank  路  3Comments

capttrousers picture capttrousers  路  3Comments