<p
v-for="(one, index) in children"
:id="'alarmId' + one.id"
:key="index"
:class="{
'alarm-oil': alarmArr.includes(one.id)
}"
>
{{ one.areaName }}
</p>
.alarm-oil{
color:red
}
alarmArr和children是要匹配的两个数组,使用es6的include方法找到两个数组内共同的id,使class生效