Reputation: 13636
I use vue2 in my project.
I have property img_path and class txt-disabled:
<script>
export default {
props: {
img_path: { required: false },
title: { required: false }
},
components: { },
computed: {},
methods: {},
};
</script>
<style>
.txt-disabled{
color:lightgray;
}
</style>
when property is empty I want to apply txt-disabled css class on span the element:
<span :class="{ img_path: txt-disabled }">{{title}}</span>
But on example above txt-disabled class not applied.
Any idea why class not applied?
Upvotes: 0
Views: 45
Reputation: 215117
You need to put css class as the key, and the condition as value, see example here:
<span :class="{ 'txt-disabled': !img_path }">{{title}}</span>
Upvotes: 1