如何检测"材质"单选按钮或组失去焦点



这就是问题所在,无法检测。我尝试过:

<mat-radio-button [value]="value" (blur)="onBlur($event)">

但徒劳无功。我理解模糊事件应该只有那个些可以聚焦的元素,而里面的材质按钮有输入元素。那么,有没有简单的解决方案而没有复杂的解决方案?提前感谢!

您可以在mat-radio-groupmat-radio-button上直接使用事件绑定(focusout)
HTML代码:

<mat-radio-group aria-label="Select an option" (focusout)="outOfFocus()">
<mat-radio-button value="1">Option 1</mat-radio-button>
<mat-radio-button value="2">Option 2</mat-radio-button>
</mat-radio-group>

TS代码:

outOfFocus(){
console.log("You reached out of focus")
}

最新更新