首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >反应中未识别属性的错误:位置,sx

反应中未识别属性的错误:位置,sx
EN

Stack Overflow用户
提问于 2022-02-03 08:34:10
回答 1查看 736关注 0票数 0

你好,我正面临这个错误,有人知道如何处理吗?错误不是识别反应中的属性:“位置”,“sx”。..............................................................................................................................................................................................................................................................................................................................................................................错误:

代码语言:javascript
复制
ERROR in src/components/TimeLine.tsx:18:13
TS2322: Type '{ children: Element[]; position: string; }' is not assignable to type 'IntrinsicAttributes & TimelineProps'.
  Property 'position' does not exist on type 'IntrinsicAttributes & TimelineProps'.
    16 | export default function CustomizedTimeline(any: any) {       
    17 |        return (
  > 18 |                <Timeline position="alternate">
       |                          ^^^^^^^^
    19 |                        <TimelineItem>
    20 |                                <TimelineOppositeContent      
    21 |                                        sx={{

ERROR in src/components/TimeLine.tsx:21:6
TS2322: Type '{ children: string; sx: { m: string; align: string; variant: string; color: string; }; }' is not assignable to type 'IntrinsicAttributes & TimelineOppositeContentProps'.
  Property 'sx' does not exist on type 'IntrinsicAttributes & TimelineOppositeContentProps'.
    19 |                        <TimelineItem>
    20 |                                <TimelineOppositeContent      
  > 21 |                                        sx={{
       |                                        ^^
    22 |                                                m: 'auto 0',  
    23 |                                                align: 'right',
    24 |                                                variant: 'body2',

以下是组件的“时间线”代码:

代码语言:javascript
复制
import * as React from 'react';
import Timeline from '@material-ui/lab/Timeline';
import TimelineItem from '@material-ui/lab/TimelineItem';
import TimelineSeparator from '@material-ui/lab/TimelineSeparator';
import TimelineConnector from '@material-ui/lab/TimelineConnector';
import TimelineContent from '@material-ui/lab/TimelineContent';
import TimelineOppositeContent from '@material-ui/lab/TimelineOppositeContent';
import TimelineDot from '@material-ui/lab/TimelineDot';
import FastfoodIcon from '@mui/icons-material/Fastfood';
import LaptopMacIcon from '@mui/icons-material/LaptopMac';
import HotelIcon from '@mui/icons-material/Hotel';
import RepeatIcon from '@mui/icons-material/Repeat';
import Typography from '@mui/material/Typography';


export default function CustomizedTimeline(any: any) {
    return (
        <Timeline position="alternate">
            <TimelineItem>
                <TimelineOppositeContent
                    sx={{
                        m: 'auto 0',
                        align: 'right',
                        variant: 'body2',
                        color: 'text.secondary',
                    }}
                >
                    8:00 am
                </TimelineOppositeContent>
                <TimelineSeparator>
                    <TimelineConnector />
                    <TimelineDot>
                        <FastfoodIcon />
                    </TimelineDot>
                    <TimelineConnector />
                </TimelineSeparator>
                <TimelineContent sx={{ py: '12px', px: 2 }}>
                    <Typography variant="h6" component="span">
                        Eat
                    </Typography>
                    <Typography>Because you need strength</Typography>
                </TimelineContent>
            </TimelineItem>
            <TimelineItem>
                <TimelineOppositeContent
                    sx={{ m: 'auto 0' }}
                    variant="body2"
                    color="text.secondary"
                >
                    9:00 am
                </TimelineOppositeContent>
                <TimelineSeparator>
                    <TimelineConnector />
                    <TimelineDot color="primary">
                        <LaptopMacIcon />
                    </TimelineDot>
                    <TimelineConnector />
                </TimelineSeparator>
                <TimelineContent sx={{ py: '12px', px: 2 }}>
                    <Typography variant="h6" component="span">
                        Code
                    </Typography>
                    <Typography>Because it&apos;s awesome!</Typography>
                </TimelineContent>
            </TimelineItem>
            <TimelineItem>
                <TimelineSeparator>
                    <TimelineConnector />
                    <TimelineDot color="primary" variant="outlined">
                        <HotelIcon />
                    </TimelineDot>
                    <TimelineConnector sx={{ bgcolor: 'secondary.main' }} />
                </TimelineSeparator>
                <TimelineContent sx={{ py: '12px', px: 2 }}>
                    <Typography variant="h6" component="span">
                        Sleep
                    </Typography>
                    <Typography>Because I need rest</Typography>
                </TimelineContent>
            </TimelineItem>
            <TimelineItem>
                <TimelineSeparator>
                    <TimelineConnector sx={{ bgcolor: 'secondary.main' }} />
                    <TimelineDot color="secondary">
                        <RepeatIcon />
                    </TimelineDot>
                    <TimelineConnector />
                </TimelineSeparator>
                <TimelineContent sx={{ py: '12px', px: 2 }}>
                    <Typography variant="h6" component="span">
                        Repeat
                    </Typography>
                    <Typography>Because this is the life I </Typography>
                </TimelineContent>
            </TimelineItem>
        </Timeline>
    );
}
EN

回答 1

Stack Overflow用户

发布于 2022-02-04 04:48:56

您是从@material/lab导入的,该包包含组件的v4 (不包含sx或位置道具)。以下是v4的API:https://v4.mui.com/api/timeline/

为了使用sx和位置道具,您需要升级您的实验室包以使用v5。v5组件在一个新的包@mui/lab中,您可以在这里找到安装信息:https://www.npmjs.com/package/@mui/lab

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70968051

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档