是否可以将变量与组件的样式标记一起使用?基本上,我已经在我的样式标签中导入了一个mixin,它接受两种 colored颜色 ,在一个类中创建一个渐变.它工作得很好,但我想要这个动态,所以我可以通过数据库设置它.我知道我可以通过内联绑定样式,但div的渐变相当长,作为混音效果更好.
组成部分:
<template>
<section class="section" v-bind:class=" { 'color-section' : content.gradient_color_one }">
<div class="container">
<div class="columns">
<div class="column is-half">
<h2 class="is-size-4" v-html="content.title"></h2>
<div class="section-content" v-html="content.description"></div>
<a class="button" :href=" '/'+ content.button_link">{{ content.button_text }}</a>
</div>
<div class="column">
<img :src="content.image" :alt="content.title" />
</div>
</div>
</div>
</section>
</template>
<script>
export default {
props:[
'content'
],
}
</script>
<style lang="scss" scoped>
@import "../../sass/helpers/混入";
.color-section{
color:red;
@include diagonalGradient( content.gradient_color_one , content.gradient_color_two);
}
</style>
混入
@mixin diagonalGradient($top, $bottom){
background: $top;
background: -moz-linear-gradient(-45deg, $top 0%, $bottom 100%);
background: -webkit-gradient(left top, right bottom, color-stop(0%, $top), color-stop(100%, $bottom));
background: -webkit-linear-gradient(-45deg, $top 0%, $bottom 100%);
background: -o-linear-gradient(-45deg, $top 0%, $bottom 100%);
background: -ms-linear-gradient(-45deg, $top 0%, $bottom 100%);
background: linear-gradient(135deg, $top 0%, $bottom 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#92fe9d', endColorstr='#00c8ff', GradientType=1 );
}