Skip to content

错误代码:

vue
<div :style="`background: url(${imageUrl})`"></div>
<div :style="`background: url(${imageUrl})`"></div>

原因:

url()参数必须是字符串,在 html 标签属性中,必须加上引号""

正确代码:

vue
<div :style="`background: url('${imageUrl}')`"></div>
<div :style="`background: url('${imageUrl}')`"></div>