v-bind:Style中的条件-VueJS

vue.js Vue.js

西门十三LEY

2020-03-12

我有一个简单的问题,希望对您有帮助:

<div>
  <figure :style="{ 'background': 'url(' + item.main_featured + ') center no-repeat' }">
</div>

如果API的URL未定义,我希望样式属性'background'返回颜色

例:

如果item.featured_photo不为null:

<figure style="background: url('localhost:6969/image.img') center no-repeat">

如果item.featured_photo为null:

<figure style="background: #FFF">

第1006篇《v-bind:Style中的条件-VueJS》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

0个回答

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android