Stepykun
Stepykun

Reputation: 13

following links in vue with button

Cheers everyone. I have encountered a problem with following links.

I need to assign link to a button. Can I wrap router-link in a button?

<template lang="html">
    <button @click="" v-if="status == 'SUCCESS'"><font-awesome-icon icon="check" /></button>
    <button @click="" v-else-if="status == 'CRASH'"><font-awesome-icon icon="times" /></button>
    <button @click="" v-else-if="status == 'NO_DATA'"><font-awesome-icon icon="minus" /></button>
    <button v-else>What?</button>
</template>

Upvotes: 0

Views: 2507

Answers (1)

Simon Hyll
Simon Hyll

Reputation: 3608

Just assign the :to="" value to your button and it'll be turned into a valid vue-router link.

For example:

<button :to="{name: 'Home'}" />

Would be turned into:

<a href="/index"></a>

Upvotes: 3

Related Questions