绑定时使用v-bind:style
效果很好color
:
<p v-bind:style="{ color: '#' + tradingCardOption.BorderColorHex }">
{{ tradingCardOption.ColorSetName }}
</p>
但是,绑定到background-color
不起作用:
v-bind:style="{ background-color: '#' + tradingCardOption.BorderColorHex }"
也不绑定到border-top
:
v-bind:style="{ border-top: 15px solid + '#' + tradingCardOption.CornerColorHex }"
是什么导致它如此有条件地工作?
<div v-for="tradingCardOption in tradingCardOptions">
<div v-bind:style="{ background-color: '#' + tradingCardOption.BorderColorHex}" class="color-swatch " v-bind:class="{'selected' : $index == 0}" v-on:click="selectTradingCardOption(tradingCardOption, $event)">
<div v-bind:style="{ border-top: 15px solid + '#' + tradingCardOption.CornerColorHex}"></div>
</div> {{ tradingCardOption.BorderColorHex}}
<p v-bind:style="{ color: '#' + tradingCardOption.BorderColorHex}"> {{ tradingCardOption.ColorSetName }}</p>
</div>