0👍
Just add computed property and bind it to style
, make template more clean:
computed: {
styles() {
if (!this.item.packageAtGradeImage.url) {
return null;
}
return { 'background-image': 'url(' + this.item.packageAtGradeImage.url + ')' };
}
}
In template:
<div :style="styles"></div>
Source:stackexchange.com