[Vuejs]-VUE, in the v-for loop, how to bind each url of the loop in the style

0👍

You can create a method to load your image and add require functionality.

export default {
        methods :{
            loadImg(url){
                return require('@/' + url );
            }
        }
    }

Your style would be

:style="{'background-image': 'url(' + loadImg('+itemA.icon+') + ')'}"

Leave a comment