我有一个简单的问题,希望你能提供帮助:
<div>
<figure :style="{ 'background': 'url(' + item.main_featured + ') center no-repeat' }">
</div>
Run Code Online (Sandbox Code Playgroud)
如果未定义API中的URL,我希望样式属性"background"返回颜色
例:
如果item.featured_photo不为null:
<figure style="background: url('localhost:6969/image.img') center no-repeat">
Run Code Online (Sandbox Code Playgroud)
如果item.featured_photo为null:
<figure style="background: #FFF">
Run Code Online (Sandbox Code Playgroud)