Created
April 18, 2019 18:35
-
-
Save webislife/6556a7c1a8f3189ae87e6cef75fb3fe1 to your computer and use it in GitHub Desktop.
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
<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