[Vuejs]-Vue styling components

0👍

Try this:

 <script>
export default {
    props: {
        source: {
            type: String,
            required: true,
        },
        style:{
            type: String,
            required:true
        }            
    },
}
</script>

<template>
  <div class="imageItem">
    <img class="image" :data-srcset="source" :style="style" />
    <p> this is some text </p>
 </div>
</template>

And then in the prop: “color:red”

<imageItem :source="source" :style="color : red" />

Leave a comment