Created
August 24, 2018 01:30
-
-
Save calebporzio/c9c0d5dc07ae72997342c5cd1e9065a7 to your computer and use it in GitHub Desktop.
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
<script> | |
export default { | |
props: ['icon'], | |
render(h) { | |
let svgHtml = require(`!html-loader!./../../svg/${this.icon}.svg`) | |
let wrapper = document.createElement('div') | |
wrapper.innerHTML = svgHtml | |
let node = wrapper.firstChild | |
let attrs = {} | |
node.getAttributeNames().forEach(name => { | |
attrs[name] = node.getAttribute(name) | |
}) | |
delete attrs.height | |
delete attrs.width | |
return h('svg', { | |
class: [ 'svg-icon' ], | |
attrs: attrs, | |
domProps: { | |
innerHTML: node.innerHTML | |
} | |
}) | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment