1、创建React项目
方法1:通过npm install create-react-app -g
,create-react-app my-appxxxxx
创建
方法2:npx create-react-app my-apxxxxxx
示例代码:
//形式1
import React, { Component } from 'react';
class Home extends Component {
constructor() {
super();
}
render(){
return <div><h1>您好!</h1></div>
}
}
export default Home;
//形式2
import React from 'react';
class Home extends React.Component {
constructor() {
super();
}
render(){
return (
<div><h1>您好!</h1></div>
)
}
}
export default Home;
网友评论