swisnl / vue-cli-plugin-svg-sprite

vue-cli 3 plugin to build an SVG sprite
MIT License
68 stars 11 forks source link

Docs are insufficient - example usage would be nice. #2

Closed makobasuri closed 5 years ago

makobasuri commented 5 years ago

I can't figure out, how to use the plugin correctly. In my vue-File, I tried using the SvgIcon component, however the element is unknown.

<template>
  <SvgIcon name="clock" xlink:href="clock" />
</template>

<script>
import clock from '@/assets/svgicons/clock.svg' // adjusted the path in vue.config.js

export default {}
</script>
RoachMech commented 5 years ago

Hi @makobasuri,

Thanks for reaching out. I will make a PR with example usage. In the meantime, try this:

<template>
    <div>
        <SvgIcon name="clock"></SvgIcon>
    </div>
</template>

<script>
    import SvgIcon from './SvgIcon.vue'

    export default {
        components: {
            SvgIcon
        }
    }
</script>

Is this working for you?

makobasuri commented 5 years ago

I was reading through the plugin section in the vue-cli docs and tried invoking the plugin and tada, the component showed up in my tree, so now i can import it as usual.

Maybe the plugin didnt get invoked, because I used vue ui to install it, or I accidentally deleted the generated SvgIcon component during development...anyway, it works now and thank you :)