怎么添加了点击事件,主题没有变色。
MenuBar:
<div class="setting-theme" v-else-if="showTag === 1">
<div class="setting-theme-item" v-for="(item,index) in themeList" :key="index" @click="setTheme(index)">
<div class="preview" :style="{background: item.style.body.background}" :class="{'no-border': item.style.body.background !== '#fff'}"></div>
<div class="text" :class="{'selected': index === defaultTheme}">{{item.name}}</div>
</div>
</div>
props:{
themeList:Array,
defaultTheme:Number
},
函数:
setTheme(index){
this.$emit('setTheme',index);
},
Ebook:
数组和变量:
themeList:[
{
name:'default',
style:{
body:{
'color':'#000',
'background':'#fff'
}
}
},
{
name:'eye',
style:{
body:{
'color':'#000',
'background':'#ceeaba'
}
}
},
{
name:'night',
style:{
body:{
'color':'#fff',
'background':'#000'
}
}
},
{
name:'gold',
style:{
body:{
'color':'#000',
'background':'rgb(241,236,226)'
}
}
}
],
defaultTheme: 0
函数:
setTheme(index){
this.themes.select(this.themeList[index].name);
console.log(index);
this.defaultTheme = index;
},
添加了主题点击事件后一直不生效,没找到原因是怎么回事