Skip to content

Instantly share code, notes, and snippets.

@nicooprat
Last active June 13, 2020 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicooprat/47de8999afd2f2f9e0622664761ca579 to your computer and use it in GitHub Desktop.
Save nicooprat/47de8999afd2f2f9e0622664761ca579 to your computer and use it in GitHub Desktop.
Render absolute path with vue-router
<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