ion-checkbox 不允许与标签交互

问题描述 投票:0回答:1
ionic-framework ion-checkbox
1个回答
0
投票

一种方法是使用 css prop z-index 和 js event.stopPropagation():

CSS

.ion-text-wrap {
  position: relative;
}

.ion-text-wrap a {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1; /* Higher z-index to make the link clickable */
}

JS

<ion-checkbox
  value={value}
  name='name'
  onIonChange={(e) => this.handleChangeCheck(e)}
  label-placement="end">
   <div class="ion-text-wrap">
      My text <a href="https://google.it" onClick={(e) => e.stopPropagation()}>click here</a>
   </div>
</ion-checkbox>
© www.soinside.com 2019 - 2024. All rights reserved.