【发布时间】:2018-07-05 11:19:04
【问题描述】:
我有一个简单的问题希望你能帮忙:
<div>
<figure :style="{ 'background': 'url(' + item.main_featured + ') center no-repeat' }">
</div>
如果来自 API 的 URL 未定义,我希望样式属性“背景”返回颜色
例子:
如果 item.featured_photo 不为空:
<figure style="background: url('localhost:6969/image.img') center no-repeat">
如果 item.featured_photo 为空:
<figure style="background: #FFF">
【问题讨论】: