reactjs 如何在typescript中声明CSS类的类型?

bvn4nwqk  于 2022-11-04  发布在  React
关注(0)|答案(1)|浏览(159)
import React, { FC } from "react";
     import { IUser } from "../types/Types";
     import App from "../App";
     interface UserItemProps {
     user: IUser;
     ClassName: React.CSSProperties;
      }
       const UserItem: FC<UserItemProps> = ({ user }) => {
        return (
         <div ClassName="UserPage">
         {user.id}.{user.name}.{user.email} lives {user.address.city} street{" "}
         {user.address.street}
         </div>
         );
        };

     export default UserItem;

CSS系统

.UserPage{
      width:1400px;
      height:hug 164px;
      border-radius:8px;
      padding:24px, 16px, 24px, 16px;
      gap:32px;

      }

错误:键入“{ children:(字符串|编号)[];类名:“string; }"无法分配给类型”“。属性”“类名”“在类型”“上不存在。您的意思是”“类名”“吗?”
我如何声明CSS类型?

o8x7eapl

o8x7eapl1#

在div组件中,您使用了className(带有大写C),需要将其写成className

<div className="UserPage">
       {user.id}.{user.name}.{user.email} lives {user.address.city} 
         street{""}
       {user.address.street}
     </div>

相关问题