如何在 ion-alert-button 中使用 Ion-router-link

问题描述 投票:0回答:1

实际上我已经创建了一个按钮,当我们单击该按钮时,它会显示警报,您确定吗?因此,当我单击“是”时,我想重定向到另一个页面或路由到另一个页面

<IonCardContent className={classes.cardContent}>
        <IonButton 
          id="present-alert"
          routerDirection="back"
          className={`${classes.approveBtn}`}
          onClick={() => showAlert()}>
          Approve
        </IonButton>
        <IonButton
          id="present-alert"  
          routerDirection="back"
          onClick={() => showAlert()}
        >
          Reject
        </IonButton>
        <IonAlert
        isOpen={alert}
        trigger="present-alert"
        header="Are you sure?"
        className="custom-alert"
        onDidDismiss={() => showAlert()}
        buttons={[
          {
            text: 'No',
            cssClass: 'alert-button-cancel',
            
          },
          {
            text: 'Yes',
            cssClass: 'alert-button-confirm',
            handler:()=> {
                <Redirect to="/admin/orders/requests" />
            }
            }
        ]}
      ></IonAlert>
        </IonCardContent>
reactjs ionic-framework button routes alerts
1个回答
0
投票
<IonAlert
    header="Alert!"
    trigger="present-alert"
    buttons={[
      {
        text: 'Cancel',
        role: 'cancel',
        handler: () => {
          console.log('Alert canceled');
        },
      },
      {
        text: 'OK',
        role: 'confirm',
        handler: () => {
          console.log('Alert confirmed');/// ==> DO ROUTING CALLS HERE
        },
      },
    ]}
    onDidDismiss={({ detail }) => console.log(`Dismissed with role: ${detail.role}`)}
  ></IonAlert>

您可以使用警报按钮来做到这一点

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.