【问题标题】:"Type '{}' is not assignable to type..." in @ionic/react whenever an element is used每当使用元素时,@ionic/react 中的 \"Type \'{}\' 不可分配给 type...\"
【发布时间】:2022-09-30 18:53:48
【问题描述】:

我正在制作一个 Ionic React 项目,最近(可能是因为更新)我的所有 @ionic/react 元素在每次使用时都会返回错误。

我的代码:

//import { useParams } from \'react-router\';
import \'./css/Page.css\';
import Login from \'../components/Login\';
import { IonButtons, IonContent, IonHeader, IonMenuButton, IonPage, IonTitle, IonToolbar } from \'@ionic/react\'
const pageName = \"Login\"

const Page: React.FC = () => {

  //const { name } = useParams<{ name: string; }>();

  // PLS FIX IDK WHY IT\'S GIVING ERRORS (it\'s @ionic/react)
  return (
    <IonPage>
      <IonHeader>
        <IonToolbar>
          <IonButtons slot=\"start\">
            <IonMenuButton />
          </IonButtons>
          <IonTitle>{pageName}</IonTitle>
        </IonToolbar>
      </IonHeader>

      <IonContent fullscreen>
        <IonHeader collapse=\"condense\">
          <IonToolbar>
            <IonTitle size=\"large\">{pageName}</IonTitle> 
          </IonToolbar>
        </IonHeader>
        {Login()}
      </IonContent>
    </IonPage>
  );
};

export default Page;

错误:

Type \'{}\' is not assignable to type \'Pick<React.HTMLAttributes<unknown>, \"id\" | \"hidden\" | \"dir\" | \"slot\" | \"title\" | \"color\" | \"translate\" | \"children\" | \"className\" | \"defaultChecked\" | \"defaultValue\" | \"suppressContentEditableWarning\" | ... 240 more ... | \"onTransitionEndCapture\"> & IonicReactProps & RefAttributes<...>\'.
  Type \'{}\' is missing the following properties from type \'Pick<React.HTMLAttributes<unknown>, \"id\" | \"hidden\" | \"dir\" | \"slot\" | \"title\" | \"color\" | \"translate\" | \"children\" | \"className\" | \"defaultChecked\" | \"defaultValue\" | \"suppressContentEditableWarning\" | ... 240 more ... | \"onTransitionEndCapture\">\': id, hidden, dir, slot, and 249 more.

在 package.json 中,@ionic/react 看起来像这样:

\"@ionic/react\": \"^6.2.9\"

请帮忙,我的项目中有 46 个错误

    标签: reactjs react-native ionic-framework ionic-react


    【解决方案1】:

    没关系,它只是自己修复了。

    【讨论】:

      猜你喜欢
      • 2018-03-20
      • 2022-08-04
      • 2017-12-24
      • 1970-01-01
      • 2019-02-08
      • 1970-01-01
      • 2018-07-20
      • 2022-11-15
      • 2017-03-21
      相关资源
      最近更新 更多