Last active
June 13, 2020 08:32
-
-
Save nicooprat/47de8999afd2f2f9e0622664761ca579 to your computer and use it in GitHub Desktop.
Render absolute path with vue-router
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<router-link v-for="(action, i) in actions" :key="i" :to="action.href" v-slot="{ href }"> | |
<mj-button :href="getAbsoluteURL(href)" font-family="Roboto, sans-serif" font-size="14px" :font-weight="action.type === 'primary' ? 'bold' : 'normal'" :background-color="action.type === 'primary' ? '#0072f0' : '#ffffff'" :color="action.type === 'primary' ? '#ffffff' : '#36404d'" padding-bottom="15px"> | |
{{ action.label }} | |
</mj-button> | |
</router-link> | |
</template> | |
<script> | |
const app = new Vue({ | |
... | |
methods: { | |
getAbsoluteURL(href) { | |
// Retrieve baseUrl as you need | |
return `${config.baseUrl}${href}` | |
}, | |
}, | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment