以图片为例,其他同理
前端代码:
<img class="tj_LJ{{i}}" (mouseover)="over3(i)" (mouseout)="out3(i)" (click)="okJian(i)" src="assets/questiondesign/77.png"/>
ts 代码:
import { Component, OnInit, ElementRef, Input } from '@angular/core';
constructor( private el: ElementRef) {
}
//鼠标悬停 逻辑 减号图标 时变换图标颜色
over3(i) {
this.el.nativeElement.querySelector('.j_LJ' + i).src = 'assets/questiondesign/44.png';
}
//鼠标悬停离开 减号图标 时变换图标颜色
out3(i) {
this.el.nativeElement.querySelector('.j_LJ' + i).src = 'assets/questiondesign/77.png';
}