怎么添加了点击事件,主题没有变色。

来源:3-10 主题设置功能实现(下)

行走的指尖

2018-09-11 16:00

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;

},

添加了主题点击事件后一直不生效,没找到原因是怎么回事

写回答 关注

2回答

  • 懒姑娘要学习了
    2019-11-08 16:09:30

    什么原因,我也遇到一样的问题了,还没找到原因

    懒姑娘要学习...

    为什么themeList下的背景色必须为background,写成backgroundColor就不行。

    2019-11-08 16:37:00

    共 1 条回复 >

  • 行走的指尖
    2018-09-11 16:11:46

    找到问题啦,嘻嘻嘻。

    慕婉清940...

    请问是怎么解决的呢

    2022-03-14 10:57:05

    共 2 条回复 >

快速入门Web阅读器开发

带你了解电子书阅读器的工作原理,通过Vue.js快速实现Web阅读器

26259 学习 · 214 问题

查看课程

相似问题