我已经看过很多不同的解决方法,但是我做不到。编译react代码时,出现错误消息,即使我通过类将其导出,也需要使用默认导出。我试过仅导出我称为探路者脚本的部分,但不起作用。
import React from 'react';
import './App.css';
import Pathfinder from './Pathfinder/Pathfinder';
function App() {
return(
<div className="App">
<Pathfinder></Pathfinder>
</div>
);
}
export default App;
Pathfinder.js
import React, {Component} from 'react';
import Node from './Node/Node';
import './Pathfinder.css';
function app(){
return(
<div>
<p>
</p>
</div>
);
}
这里有很多可疑的事情,尤其是您有一个app
组件和一个App
组件。但是随着错误的传达,您并没有app
在Pathfinder.js中导出组件。肮脏的修复:
export default function app() {
// ...
}
不过,至少我会将函数重命名为Pathfinder
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句