即使在app.js中导入样式后,Ionic React样式也不会呈现

fgw7neuy  于 2022-12-08  发布在  Ionic
关注(0)|答案(1)|浏览(184)

I'm trying to use the ionic ui library( @ionic/react ) to create the interface of my app.
I've included the core.css file from ionic.
But the components render without styles.
Following is the code in my App.js

import React from 'react'
import { IonButton } from '@ionic/react';

import '@ionic/react/css/core.css';

const App = () => {
  return (
    <>
      <IonButton color="primary">Primary</IonButton>
      <IonButton color="secondary">Secondary</IonButton>
      <IonButton color="tertiary">Tertiary</IonButton>
      <IonButton color="success">Success</IonButton>
      <IonButton color="warning">Warning</IonButton>
      <IonButton color="danger">Danger</IonButton>
      <IonButton color="light">Light</IonButton>
      <IonButton color="medium">Medium</IonButton>
      <IonButton color="dark">Dark</IonButton>
    </>
  )
}

export default App

check this image to see the result
dependencies versions: -
"@ionic/react": "^6.0.9",
"react": "^16.13.1",

qkf9rpyu

qkf9rpyu1#

**注意 *:ionicframework.com/docs/intro/upgrading-to-ionic-6#react

开发人员必须导入和调用setupIonicReact,即使他们没有设置自定义配置。
输入,应用程序tsx

import { setupIonicReact } from '@ionic/react';
 
setupIonicReact();

相关问题