Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing SVG as a prop #26

Closed
Scaalees opened this issue Sep 20, 2019 · 4 comments
Closed

Passing SVG as a prop #26

Scaalees opened this issue Sep 20, 2019 · 4 comments

Comments

@Scaalees
Copy link

I'm passing an imported SVG as a prop to my component. However my component is just rendering the <img /> tag rather than converting to a SVG.

Parent component

<template>
  <div>
    <child-component :svg="SVG" />
  </div>
</template>
<script>
  import SVG from '@/assets/svgs/my-svg.svg';
  export default {
    data: () => ({
       SVG
    })
  }
</script>

Child component

<template>
  <div>
    <img svg-inline :src="parentSVG" /> 
  </div>
</template>
<script>
  export default {
      props: {
        type: String,
        required: true,
      }
  }
</script>

Renders as

<img svg-inline="" src="/_nuxt/assets/svgs/my-svg.svg">

I'm using the standard nuxt config.

@mrleblanc101
Copy link
Contributor

Did you read the doc ?
This only work for img in the template.
Not img imported via JS

@oliverfindl
Copy link
Owner

Hello,

please check my answer here.

If you have any questions, feel free to ask.

Thanks

@Scaalees
Copy link
Author

No worries at all. Sorry for the confusion, didn't quite see the notice about it being only static

@adrianthedev
Copy link

This extension helped me out in the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants