Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vue.js 如何在Vue中将颜色作为道具发送?_Vue.js_Vue Component - Fatal编程技术网

Vue.js 如何在Vue中将颜色作为道具发送?

Vue.js 如何在Vue中将颜色作为道具发送?,vue.js,vue-component,Vue.js,Vue Component,这是我的Button vue对象。我想根据道具改变颜色 <template> <div class="get-started-btn flex center" style="cursor: pointer; padding: 0px 15px; height: 36px; color: {{color}} "> {{text}} </di

这是我的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>

{{text}}
导出默认值{
名称:“按钮”,
道具:{
文本:字符串,
颜色:字符串,
背景颜色:字符串,
}
}
.开始使用btn{
背景色:{{backgroundColor}};
}
例如:

    <Button text="Mark As Done" color="white" backgroundColor="#1cb86e"></Button>


但它不是在编译


<Button text="Get Started" :style="{ 'background-color': YOURCOLORVARIABLEHERE }"></Button>
我想你可以看看那篇文章

他们准确地解释了你想做什么。

检查此链接是否有帮助:
<Button text="Get Started" :style="{ 'background-color': YOURCOLORVARIABLEHERE }"></Button>