模块构建失败:重复声明

时间:2018-05-01 05:07:50

标签: javascript reactjs antd

我在我的React项目中使用Ant Design Framework。但是在导入组件时,即使我之前没有声明这些组件,它也会出错。

ERROR:

Module build failed: Duplicate declaration "Icon"

以下是代码:



// App.js

import React from 'react';
import ReactDOM from 'react-dom';
import { FullSpinner } from "./Spinner"

class App extends React.Component {
  render() {
    return (<div>sdkfjsdf</div>)
  }
}

export default App 
&#13;
&#13;
&#13;

&#13;
&#13;
// Spinner.js

import { Spin, Icon } from 'antd';

import React from 'react'
import {Icon, Spin} from 'antd';

const antIcon = () => <Icon type="loading" style={{ fontSize: 24 }} spin />;


export const FullSpinner = () => <Spin indicator={antIcon} />
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:2)

您已多次导入Icon组件。

// Spinner.js

import { Spin, Icon } from 'antd';
import React from 'react'
import {Icon, Spin} from 'antd';  <- Duplicate

const antIcon = () => <Icon type="loading" style={{ fontSize: 24 }} spin />;
export const FullSpinner = () => <Spin indicator={antIcon} />

import { Spin, Icon } from 'antd';

中删除Spinner.js后尝试

答案 1 :(得分:1)

您的test_var.shape (20000, 10) test_var [[ 6. 6. 6. ..., 10. 10. 10.] [ 10. 10. 10. ..., 3. 3. 3.] [ 6. 6. 6. ..., 11. 10. 10.] ..., [ 6. 6. 6. ..., 10. 10. 10.] [ 6. 6. 6. ..., 11. 10. 10.] [ 6. 6. 6. ..., 11. 10. 10.]] 文件正在从Spinner.js模块导入SpinIcon两次。您可以安全地删除其中一行。

antd