Answer the question
In order to leave comments, you need to log in
How to use a sprocket asset in a Vue component?
An existing project is smoothly transitioning to webpacker and vue. How to use any type of asset, whether it's an assembled svg sprite that is used when rendering in views that Vue doesn't manage, or just a jpg image. I want to use the same sprite from inside the vue component. In general, how are any resources from the app/assets folder connected inside the vue component?
mysupercomponent.vue
<template lang="haml">
<template lang="haml">
%div
#avatar-pattern
#title-username {{name}}
#set-avatar
%svg
%use{'xlink:href': "#{asset_path 'icons.svg'}#icons-avatar"}
</template>
<svg><use xlink:href="#{asset_path 'icons.svg'}#icons-search"></use></svg>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question