![](/img/trans.png)
[英]import statement doesn't throw any error when a exported property is not defined in the export file
[英]Error file is not defined in React (won't export)
在學習教程時不斷收到錯誤:
src/components/MyApp.js
Line 17:18: 'myApp' is not defined no-undef 搜索關鍵字以了解有關每個錯誤的更多信息。
這是我的myApp.js
:
import React from 'react'
function MyApp() {
return (
<div>
<h1>hello world</h1>
<p>hello world</p>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</div>
)
}
export default myApp
這是我的index.js
:
import React from 'react';
import ReactDOM from 'react-dom';
import MyApp from './components/MyApp.js';
ReactDOM.render(<MyApp />, document.getElementById('root'))
它在 function 中可以正常工作,但是如果我嘗試將其取出並將其放入新文件夾中,它將無法讀取。
謝謝你。 這就是文件的外觀。
這是一個拼寫錯誤。 ( export default
)。
import React from 'react'
function MyApp() {
return (
<div>
<h1>hello world</h1>
<p>hello world</p>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</div>
)
}
export default MyApp
我能夠通過刪除所有內容並重新開始來運行所有內容。 我覺得好像有一個反應文件放錯了地方,它只是無法讀取 MyApp.js。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.