Created
June 5, 2018 23:44
-
-
Save kazzkiq/f5a1f4222971763090beab8cc1f60a0e to your computer and use it in GitHub Desktop.
Link Svelte Component (which replaces <a>)
This file contains 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
<a href="{href}" class="LinkComp {cssClass || ''}" on:click="handleHref(href, event)"> | |
<slot></slot> | |
</a> | |
<script> | |
import roadtrip from 'roadtrip'; | |
export default { | |
data() { | |
return { | |
cssClass: '' | |
} | |
}, | |
methods: { | |
handleHref(path, e) { | |
e.preventDefault(); | |
roadtrip.goto(path); | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment