【问题标题】:How to move Cancel button to the right in IonSearchbar in Ionic React如何在 Ionic React 的 IonSearchbar 中将取消按钮移动到右侧
【发布时间】:2021-11-24 11:41:58
【问题描述】:

我尝试在 Ionic React 中创建搜索栏,但取消按钮位于左侧而不是右侧。这是我的代码:

<IonHeader>
  {searchActive? <IonSearchbar slot="start" showCancelButton="never">
    <IonButton slot="end" fill="clear" onClick={()=>{setSearchActive(false);}} >Cancel</IonButton>
    </IonSearchbar> : null }
  
</IonHeader>

你能帮我把取消按钮移到右边吗?

【问题讨论】:

    标签: reactjs ionic-framework ionic-react


    【解决方案1】:

    您必须将插槽更改为结束。

    <IonHeader>
      {searchActive? <IonSearchbar slot="end" showCancelButton="never">
        <IonButton slot="end" fill="clear" onClick={()=>{setSearchActive(false);}} >Cancel</IonButton>
        </IonSearchbar> : null }
    </IonHeader>
    

    https://www.joshmorony.com/understanding-how-slots-are-used-in-ionic-4/

    【讨论】:

      猜你喜欢
      • 2021-05-06
      • 2020-03-01
      • 2022-11-04
      • 1970-01-01
      • 2023-02-14
      • 2020-03-03
      • 1970-01-01
      • 2017-08-17
      • 1970-01-01
      相关资源
      最近更新 更多