I assume you are using the v-expansion-panel
component from Vuetify.
Problem : Dynamically change the icon or the background-color of v-expansion-panel-header
Solution : The component offers a prop called expand-icon
which allows to change the icon of the v-expansion-panel-header
- or via action
slot
<v-expansion-panel-header expand-icon="mdi-check" disable-icon-rotate>
Item
</v-expansion-panel-header>
<v-expansion-panel-header :expand-icon="icon" disable-icon-rotate>
Item
</v-expansion-panel-header>
<v-expansion-panel-header disable-icon-rotate>
Item
<template v-slot:actions>
<v-icon color="teal">
mdi-check
</v-icon>
</template>
</v-expansion-panel-header>
<v-expansion-panel-header disable-icon-rotate>
Item
<template v-slot:actions>
<v-icon color="teal">
{{ icon }}
</v-icon>
</template>
</v-expansion-panel-header>
Please note the use of disable-rotate-icon
to disable icon rotation when the expansion panel opens.
If you're not sure how this should be applied using Vue I suggest reading a quick Getting Started guide. However I drafted a quick example using the vuetify components in this CodeSandbox Example. Please see this example just as a pointer, there would be 100 of ways how to implement this in an app. Like this, it's not meant to use in production code.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…