Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
239 views
in Technique[技术] by (71.8m points)

reactjs - IonInput losing autofocus

I'm trying to implement an input with the autofocus attribute, it is working when I'm using it alone, but when I add an IonButton it's not working.

This is my code, I removed all of the unnecessary code to simplify the question:

import { IonContent, IonPage, IonInput, IonButton } from '@ionic/react';
import React from 'react';

const Home: React.FC = () => {
  return (
    <IonPage>
      <IonContent fullscreen>
        <IonInput autofocus></IonInput>

        <IonButton size="default" className="btn center" type="submit">
          Login
        </IonButton>
      </IonContent>
    </IonPage>
  );
};

export default Home;

Why is that?, the button needs to be of type submit because it's inside a form

Edit

I also tried with <input type="submit"> and it worked, but it also fails with <input type="button"> and I would like to use it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...