[英]images are not rendering on react.js
I create a react app and make a test component and I try to render it and it didn't render我创建了一个反应应用程序并制作了一个测试组件,我尝试渲染它但它没有渲染
this is the component: https://i.stack.imgur.com/vsNH1.png这是组件: https : //i.stack.imgur.com/vsNH1.png
and this is the main App.js file: https://i.stack.imgur.com/P8lY7.png这是主要的 App.js 文件: https ://i.stack.imgur.com/P8lY7.png
and this is my result: https://i.stack.imgur.com/mQrFd.png这是我的结果: https : //i.stack.imgur.com/mQrFd.png
why is my test component not rendering?为什么我的测试组件没有渲染?
React components must begin with a capital letter. React 组件必须以大写字母开头。 Non-capitalized names are considered by JSX to be just regular HTML tags (like
div
), so your output markup will be just <test />
. JSX 认为非大写名称只是常规的 HTML 标签(如
div
),因此您的输出标记将只是<test />
。
Quoth the JSX documentation :引用JSX 文档:
The first part of a JSX tag determines the type of the React element.
JSX 标签的第一部分决定了 React 元素的类型。
Capitalized types indicate that the JSX tag is referring to a React component.
大写类型表示 JSX 标签指的是 React 组件。 These tags get compiled into a direct reference to the named variable, so if you use the JSX expression, Foo must be in scope.
这些标签被编译成对命名变量的直接引用,所以如果你使用 JSX 表达式,Foo 必须在范围内。
Your test
component must be named Test
.您的
test
组件必须命名为Test
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.