A
A
Anton Misyagin2018-11-10 00:50:09
Ruby on Rails
Anton Misyagin, 2018-11-10 00:50:09

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>

this is not
how some_view.html.haml works
<svg><use xlink:href="#{asset_path 'icons.svg'}#icons-search"></use></svg>

that's how it works

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question