vue根据图片颜色改变背景色,UI框架vant
利用v-bind属性给div设置style属性,利用vant
changeBanner(index){
this.bgColor = this.bannerList[index].color
}
v-bind:style="{background:'#'+bgColor}"
<template>
<div>
<!-- 搜索+导航 -->
<div class="bg-animation" v-bind:style="{background:'#'+bgColor}">
<van-search
v-bind:style="{background:'#'+bgColor}"
v-model="search"
shape="round"
placeholder="请输入关键词"
@search="onSearch()"
>
</van-search>