I am trying to create component where I will set 2 properties:
- string property for class name which should be set
- boolean property which resolve if this class will be added
my component looks like this:
<template>
<span v-bind:class="{ classProp : booleanProp}"></span>
</template>
<script>
export default {
props: {
classProp: {
type: String,
default: 'bg-alert'
},
booleanProp: {
type: Boolean,
default: false
}
}
</script>
When I use this component as you can see in following code span element has class classProp instead of bg-success
<my-component :booleanProp="true" :classProp="bg-success"></my-component>
required output:
<span class="bg-success"></span>
given output:
<span class="classProp"></span>
Thanks for answers.