gpt4 book ai didi

reactjs - 无法读取未定义的属性 'Component'

转载 作者:行者123 更新时间:2023-12-04 00:04:24 24 4
gpt4 key购买 nike

每当我想使用 Ant design Component我发现这个标题有错误:

antd.min.js:23 Uncaught TypeError: Cannot read property 'Component' of undefined
at Object.<anonymous> (antd.min.js:23)
at t (antd.min.js:7)
at Object.<anonymous> (antd.min.js:31)
at t (antd.min.js:7)
at Object.<anonymous> (antd.min.js:50)
at t (antd.min.js:7)
at Object.<anonymous> (antd.min.js:7)
at t (antd.min.js:7)
at antd.min.js:7
at antd.min.js:7

我使用的是最新版本(3.7.3)

在这部分我使用了 Layout Component Ant 设计:
import React, {Component} from 'react';

import ReactDOM from 'react-dom';

import { Layout, Menu, Icon } from 'antd';

const { Header, Content, Footer, Sider } = Layout;

ReactDOM.render(
<Layout>
<Sider
breakpoint="lg"
collapsedWidth="0"
onBreakpoint={(broken) => { console.log(broken); }}
onCollapse={(collapsed, type) => { console.log(collapsed, type); }}
>
<div className="logo" />
<Menu theme="dark" mode="inline" defaultSelectedKeys={['4']}>
<Menu.Item key="1">
<Icon type="user" />
<span className="nav-text">nav 1</span>
</Menu.Item>
<Menu.Item key="2">
<Icon type="video-camera" />
<span className="nav-text">nav 2</span>
</Menu.Item>
<Menu.Item key="3">
<Icon type="upload" />
<span className="nav-text">nav 3</span>
</Menu.Item>
<Menu.Item key="4">
<Icon type="user" />
<span className="nav-text">nav 4</span>
</Menu.Item>
</Menu>
</Sider>
<Layout>
<Header style={{ background: '#fff', padding: 0 }} />
<Content style={{ margin: '24px 16px 0' }}>
<div style={{ padding: 24, background: '#fff', minHeight: 360 }}>
content
</div>
</Content>
<Footer style={{ textAlign: 'center' }}>
Ant Design ©2018 Created by Ant UED
</Footer>
</Layout>
</Layout>,
document.getElementById('main'));

但不幸的是我遇到了错误,而我只是复制了 antdesign代码。我不知道是什么问题,请帮助我。

最佳答案

这有点晚了,但这听起来像是 typescript 错误。如果其他人遇到此更改

import React, {Component} from 'react'


import * as React from 'react'

关于reactjs - 无法读取未定义的属性 'Component',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51593464/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com