Skip to content

Instantly share code, notes, and snippets.

@webislife
Created April 18, 2019 18:35
Show Gist options
  • Save webislife/6556a7c1a8f3189ae87e6cef75fb3fe1 to your computer and use it in GitHub Desktop.
Save webislife/6556a7c1a8f3189ae87e6cef75fb3fe1 to your computer and use it in GitHub Desktop.
<template>
<svg class="bgln__icon" :viewBox="svg.viewBox">
<slot></slot>
<use :xlink:href="location + '#' + svg.id" />
</svg>
</template>
<script>
export default {
name: 'icon',
data() {
return {
svg: {
content: '',
id: '',
viewBox: '',
},
location: ''
};
},
props: {
name: {
type: String,
required: true
},
},
serverCacheKey: props => props.name,
created () {
if(this.name === "" || this.name === undefined) {
APP.log.error('Undefined icon name')
} else {
let icon = require('@root/assets/svg/'+this.name+'.svg');
this.svg = icon.default;
}
},
mounted() {
this.location = location.origin + location.pathname + location.search;
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment