【问题标题】:ion-radio default checked *ngforion-radio 默认选中 *ngfor
【发布时间】:2022-07-01 23:55:36
【问题描述】:

我是离子框架的新手。我的任务是下一个,我想要,当打开组件时,应该默认选中单选按钮。我想要一个被检查。提前谢谢

在此处输入图片说明

Screen image

file typescript

tools.component.html

【问题讨论】:

    标签: angular ionic-framework radio-button ion-radio-group


    【解决方案1】:

    我还没有真正理解您的组件的含义,但我想说将您的“radioList”变量初始化为 0 就足够了。

    此外,最好使用 ColorValueObjInterface 的 id。 它会在你的 .ts 中给出

    radioList:number = colorValueObj[0]?.id || 0;
    

    还有你的 .html

    ...
    <ion-radio type="radio" [value]="item.id" name...></ion-radio>
    ...
    

    请使用代码示例 btn 发布您的代码

    【讨论】:

      猜你喜欢
      • 2018-11-04
      • 2020-12-28
      • 2017-11-26
      • 2011-04-09
      • 1970-01-01
      • 2017-12-18
      • 2018-08-07
      • 2016-04-09
      • 2018-06-24
      相关资源
      最近更新 更多