Description
In .vue template, we usually use img tag to show a image, like
<img src="./link/to/image.png">
which is OK.
However sometime we need to use background-image within inline style property:
<div style="background-image: url(./link/to/image.png)"
But it's not working, somehow I need to write it like this:
<div :style="{'background-image': 'url(' + require('./link/to/image.png') + ')'}">
or the ES2015 way:
<div :style="{'background-image': `url(${require('./link/to/image.png')})`}">
which is still not neat.
So I'm just wondering is there any better way to do this?
Metadata
Metadata
Assignees
Labels
No labels