Vue.js data-bind style backgroundImage not working

后端 未结 9 1317
耶瑟儿~
耶瑟儿~ 2020-12-12 16:18

I\'m trying to bind the src of an image in an element, but it doesn\'t seem to work. I\'m getting an \"Invalid expression. Generated function body: { backgroundImage:{ url(

9条回答
  •  半阙折子戏
    2020-12-12 16:32

    I tried @david answer, and it didn't fix my issue. after a lot of hassle, I made a method and return the image with style string.

    HTML Code

    Method

    bannerBgImage(image){
        return 'background-image: url("' + image + '")';
    },
    

提交回复
热议问题