I am creating a component (vue 2.6) and just realised that if the attribute class
is not hyphenated actually doesn't deliver the string to the component. And other attributes with no hyphenated names do deliver their values. This is how my code looks like:
Component:
<template>
<video
controls
:class="cssClass"
>
<source :src="videoSource" type="video/mp4"/>
</video>
</template>
<script>
export default {
name: 'VideoComponent',
props: {
videoSource: { type: String, default: '' },
cssClass: { type: String, default: '' },
},
};
</script>
How I am using it:
<VideoComponent
v-if="selectedAsset.type == 'video'"
css-class="cssClassName"
:videoSource="selectedAsset.videoSource"
/>
So if I name the attribute cssClass
and not css-class
when I am using it in the father component, VideoComponent
does not receive it and is empty BUT videoSource
works fine...
Why it works with some attributes and the others not?
To use same naming for attributes and properties when I use a component.