【问题标题】:ionic3 update checkbox event valueionic3 更新复选框事件值
【发布时间】:2017-12-18 21:03:06
【问题描述】:

我试图确定当用户单击复选框时是否选中了复选框。

下面是代码

 <ion-item-group>
                  <ion-item-divider color="light"><ion-icon name="warning" style="color:#FFBA55"></ion-icon>&nbsp;Overdue Tasks</ion-item-divider>
                  <ion-item> <ion-label class="label-style">item 1</ion-label>
                              <ion-checkbox (ionChange)="updateToDo($event)"></ion-checkbox></ion-item>
                  <ion-item> <ion-label class="label-style">item 2</ion-label>
                              <ion-checkbox (ionChange)="updateToDo($event)"></ion-checkbox></ion-item>

                </ion-item-group>

updateTodo 看起来像:

updateToDo(event){

    alert(event.target.checked)
  }

但这会为事件的目标属性引发未定义的操作。

【问题讨论】:

    标签: ionic3


    【解决方案1】:

    我认为checked 是传递给函数的事件的属性。

    您可以简单地使用event.checked 而不是event.target.checked

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-05
      • 1970-01-01
      • 2013-08-03
      • 2011-01-07
      • 2011-08-30
      相关资源
      最近更新 更多