Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

261
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda