简体   繁体   English

./src/index.js 尝试导入错误:“./App.js”不包含默认导出(导入为“App”)

[英]./src/index.js Attempted import error: './App.js' does not contain a default export (imported as 'App')

Below is the index.js code.下面是 index.js 代码。 Below error ./src/index.js Attempted import error: './App.js' does not contain a default export (imported as 'App') How to solve this?下面的错误 ./src/index.js Attempted import error: './App.js' does not contain a default export (imported as 'App') 如何解决这个问题?

I guess your code was like this,since I cant see your code I am attaching mine.See at the bottom line of the code,add that export default app line in your code as mentioned,You'll good to go then I believe.我猜你的代码是这样的,因为我看不到你的代码,所以我附上了我的代码。在代码的最后一行,如上所述,在你的代码中添加导出默认应用程序行,然后我相信你会很高兴的。

import React from 'react';
import logo from './logo.svg';
import './App.css';

function App() {
  return (
    <div className="App">
      <header className="App-header">
        <img src={logo} className="App-logo" alt="logo" />
        <p>Edit <code>src/App.js</code> and save to reload.</p>
        <a className="App-link"href="https://reactjs.org"target="_blank"rel="noopener noreferrer" >
          Learn React
        </a>
      </header>
    </div>
  );
}
export default App;

在“App.js”文件的底部,添加以下行:

export default App;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 index.js 尝试导入错误:“./App”不包含默认导出(导入为“App”) - index.js attempted import error: './App' does not contain a default export (imported as 'App') 尝试导入错误:“./components”不包含默认导出(导入为“App”) - Attempted import error: './components' does not contain a default export (imported as 'App') ./src/components/styles.js 尝试导入错误:&#39;@material-ui/core/styles&#39; 不包含默认导出(作为 &#39;makeStyles&#39; 导入) - ./src/components/styles.js Attempted import error: '@material-ui/core/styles' does not contain a default export (imported as 'makeStyles') React JS 尝试导入错误:&#39;./Pathfinder/Pathfinder&#39; 不包含默认导出(导入为 &#39;Pathfinder&#39;) - React JS Attempted import error: './Pathfinder/Pathfinder' does not contain a default export (imported as 'Pathfinder') [React.js] 尝试导入错误:&#39;./registerServiceWorker&#39; 不包含默认导出(导入为 &#39;registerServiceWorker&#39;) - [React.js]Attempted import error: './registerServiceWorker' does not contain a default export (imported as 'registerServiceWorker') 尝试导入错误:“firebase/app”不包含默认导出(导入为“firebase”) - Attempted import error: 'firebase/app' does not contain a default export (imported as 'firebase') 导入错误:“./App”不包含默认导出(导入为“App”) - import error: './App' does not contain a default export (imported as 'App') 尝试导入错误:“./movieReducer”不包含默认导出(导入为“movieReducer”) - Attempted import error: './movieReducer' does not contain a default export (imported as 'movieReducer') &#39;react-router&#39;不包含名为&#39;browserHistory&#39;的导出。 来自/src/App.js - 'react-router' does not contain an export named 'browserHistory'. from /src/App.js 无法从./app.js加载./src/routes/index.js中的路由 - Cannot Load Routes in ./src/routes/index.js from ./app.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM