This is my Button vue Object. I want to change the color based on the props
<template>
<div class="get-started-btn flex center"
style="cursor: pointer;
padding: 0px 15px;
height: 36px;
color: {{color}} ">
{{text}}
</div>
</template>
<script>
export default {
name: "Button",
props:{
text:String,
color: String,
backgroundColor: String,
}
}
</script>
<style scoped>
.get-started-btn{
background-color: {{backgroundColor}};
}
</style>
For example:
<Button text="Mark As Done" color="white" backgroundColor="#1cb86e"></Button>
or
<Button text="Get Started" color="white" backgroundColor="#299ff6"></Button>
But it is not compiling
<Button text="Get Started" :style="{ 'background-color': YOURCOLORVARIABLEHERE }"></Button>
I Think you can take a look on that article https://alligator.io/vuejs/dynamic-styles/
They explain exactly what you wanna do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With