reactjs - 无法从其他文件夹加载文件
问题描述
该项目是全新的(创建create-react-app
),就像我一样react
。红色所有关于babel
和的帖子webpack
。安装它,弹出它和我找到的所有东西。错误是:
Error in ./components/MyInfo.js
Module parse failed: /var/www/html/react/myfirstapp/components/MyInfo.js Unexpected token (5:8)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (5:8)
@ ./src/index.js 13:14-45
如果它与它MyInfo.js
在同一个文件夹中index.js
工作正常。将其移动到components
文件夹后发生错误。我的信息:
import React from "react"
function MyInfo() {
return (
<div>
<h1>Toma</h1>
<p>My name is Toma</p>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</div>
)
}
export default MyInfo
索引.js:
import React from "react"
import ReactDOM from "react-dom"
import MyInfo from "../components/MyInfo"
ReactDOM.render(
<MyInfo />,
document.getElementById("root")
)
解决方案
推荐阅读
- sql - 有没有办法在 ID 主键中创建另一个值?
- apache-calcite - 自定义 Calcite 的 Sql 解析器
- python - 'xml.etree.ElementTree.ParseError: no element found' 制作 python 类时
- python - 如何防止使用 os.listdir 将相同的文件添加到列表中?
- angular - spring 无法从角度请求中接收 csrf 令牌
- azure-data-factory - 使用凭据将 Azure 数据工厂连接到逻辑应用
- c# - 在 Polly 重试尝试中获取完整的 URI?
- cypress - 如何使用 cypress 验证浏览器错误的消息
- java - 我无法理解 Java 11-version2 中的这个 lastindexof 方法
- java - zeppelin-0.9.0-preview1 在少数系统上无法启动