Vue.js adds a single attribute based on the condition.

I have a component in

Vue.js:

<Carousel autoplay v-model="CarouselValue" class="physical-carousel">

I want to decide whether autoplay is added or not based on a condition.

for example, in data, I have an attribute of loading.

what if loading is false, and then autoplay is added as an attribute in this < Carousel > component?

Feb.28,2021

props, of normally defined boolean type can be bound to a Boolean value, only a Boolean value. All other values are true, including empty strings, and all are true. The rest of these native boolean type properties, such as input's disabled, also follow this rule.

:autoplay="val"
val = true/false
Menu