【发布时间】:2019-09-28 14:13:22
【问题描述】:
这是我的 Button vue 对象。我想根据道具改变颜色
<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>
例如:
<Button text="Mark As Done" color="white" backgroundColor="#1cb86e"></Button>
或
<Button text="Get Started" color="white" backgroundColor="#299ff6"></Button>
但它没有编译
【问题讨论】:
-
检查此链接是否有帮助:stackoverflow.com/questions/42872002/…
标签: vue.js vue-component