简体   繁体   中英

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>

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM