You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
424 B
25 lines
424 B
// 类组件的创建和渲染
|
|
|
|
// 导入 React 包
|
|
import React from 'react'
|
|
|
|
// 创建
|
|
class HelloComponent extends React.Component {
|
|
render() {
|
|
return <div>this is class Component</div>
|
|
}
|
|
}
|
|
|
|
function App() {
|
|
return (
|
|
<div>
|
|
{/* 渲染类组件 */}
|
|
{/* 第一种: */}
|
|
<HelloComponent />
|
|
{/* 第二种 */}
|
|
<HelloComponent></HelloComponent>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default App
|