【发布时间】:2019-12-11 15:13:07
【问题描述】:
我有 Vue.js 应用程序,并且有一个组件,代码如下:
1) 在“模板”部分:
<panel
:collapsible="true"
title="Basic section"
:iscollapsed="false"
class="category-panel"
:class="className"
>
2) 在“数据”部分:
className: '',
3) 在“方法”部分:
toggleColor () {
if (!this.document.docDate) {
this.className = 'panel >>> .panel-title-red'
}
},
async save () {
this.toggleColor()
...
}
4) 在“风格”部分:
.panel >>> .panel-title
font-weight 400
.panel >>> .panel-title-red
font-weight 400
color red
面板标题使用“样式”部分的第一类,即面板标题的颜色为黑色。当我单击“保存”按钮时,我调用了 toggleColor 方法,在某些情况下我想将颜色更改为红色。它不能以这种方式工作。如何让它发挥作用?
【问题讨论】:
标签: vuejs2