Vue.directive('sColor', {
bind: function (el, binding) {
console.log(binding);
el.style.color = binding.value == '请选择' ? '#999' : '#1F2D45'
},
update: function (el, binding) {
el.style.color = binding.value == '请选择' ? '#999' : '#1F2D45'
}
})
<div class="item">
<label>所在城市</label>
<div class="list_data" v-sColor="params.provinceName" @click="showPopup = 1" >
{{params.provinceName == '请选择' ? '请选择' : params.provinceName + '-' + params.cityName}}
<van-icon name="arrow" />
</div>
</div>