reactjs - 我有这个问题,尽管没有更改 create-react-app 上的任何配置,但我的反应组件没有呈现
问题描述
我假设它与 create-react-app 更新有关。通常在我以前的项目中,当检查页面时,我会看到每个组件都分解为它的 html 标签,但现在它只显示组件的名称,而组成组件的标签不会显示。
//App.js
import React from 'react';
import logo from './logo.svg';
import './App.css';
import heading from './head';
function App() {
return (
<div>
<heading/>
</div>
);
}
export default App;
//head.js
import React from 'react';
const head = () => {
return (
<h1>hello</h1>
)
}
export default head;
此代码在不更改 create-react-app 配置的情况下仍会显示空白页输出
解决方案
组件名称必须以大写开头:
// rest of imports ...
import Heading from './head';
function App() {
return (
<div>
<Heading/>
</div>
);
}
export default App;
推荐阅读
- angular - Ionic 3 app.component.ts 显示红线错误且无法正常工作
- python - AttributeError:“NoneType”对象在迭代列表的行时没有属性“items”
- javascript - XMLHttpRequest 没有停止
- html - 如何在 html 文本搜索中忽略短代码
- django - 有条件地返回 def __str__(self)
- c# - Xamarin iOS UIAlertController 未显示
- javascript - 如何将颜色更改为数组字符串中的特定单词?: Javascript/ jQuery
- html - 嵌套 div 高度和溢出
- java - 如何创建正确的“this”对象作为参数?
- javascript - 在 JS 和 html 中添加 off 选项值