question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to define background image in vue style block?

See original GitHub issue

How do you reference an image in your src/assets/images folder in your style in your vue component?

This is not working… The doc suggests moving the image to the static folder… but why would I want two images folders in my project?

<style lang="stylus"> 
.help
    background-image url('/assets/images/help.png')
</style>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

19reactions
krstic-ducicommented, May 11, 2019

Hello @jamelt can you please try this line of code background-image: url(~@/assets/images/name-of-image.png) ?

I had some similar issue with images via CSS and this code above solved my problem, I hope it will also solve yours.

13reactions
grevencommented, Jul 16, 2019

I know this is closed, but this definitely needs to be documented. I lost so much time looking into a way to reference an image in the assets folder directly in CSS.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to add a Background Image in Vue.js - Reactgo
In this tutorial, we are going to learn about different ways to add a backgroundImage in the vue app by using inline styles....
Read more >
How to add a background image in Style Tag in Vuejs - Medium
After you have created your Vuejs project, you need to add a background image. ... However, adding it in the App.vue file, below...
Read more >
Vue Bootstrap 5 Background Image - examples & tutorial
Learn how to create a responsive background image with the newest Bootstrap 5 and Vue 3. Many examples and ready-to-use solutions.
Read more >
Vue.js data-bind style backgroundImage not working
Within a Vue component, it worked for me just to say v-bind:style="{ 'background-image': url(image) }" , but outside of a component (just on...
Read more >
VueJS background image URL – Dev Bay – front-end tips
I will show you in this article how to set in Vuejs the background image URL to display right content in dynamic way....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found