Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

260
Views
Background image-set() doesn't work with Vue's v-bind:style

I am currently using Vue's v-bind:style to set the background of a div. This works fine. However, I am now trying to use background in combination with image-set(). Where a regular background-image is shown, the image-set() as a value returns nothing at all.

I made a very simple copy on JSbin which suprisingly works, which makes me clueless. Because whenever I try this local, no images are shown. I also don't get any errors or warnings in the console or by Grunt.

A very simplified version of the code is:

new Vue({
el: "#app",
data: { },
methods: {
  bg: function () { 
    /* Test image, is dynamic in code */
    var url = "https://picsum.photos/200/200.webp";
    var bg;
    /* This background works locally */
    bg = "background-image: url('"+ url +"');";
    /* This doesn't work locally */
    bg = "background-image:-webkit-image-set(url('"+ url +"')2x,url('"+ url +"')2x);background-image:image-set(url('"+ url +"')2x,url('"+ url +"')2x);"; 
    return bg;
  }
 }

});

The HTML looks like this:

<div id="app">
  <div class="test"  v-bind:style="bg()"></div>
  </div>

I am very new to Vue and I'd understand it's hard to debug a working code (since the JSBin is working). But perhaps the more experienced people here have an idea in what direction I could look.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Apparantly above works well in versions below 2.0.8. From this version on it stops working for whatever reason. I didn't find a solution yet to make it work in newer versions. For now I downgraded my Vue version.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!