多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] ## 用命令行 cd到E盘下 > E: ## 1.创建一个react的文件 ``` // 是npx 不是 npm (被坑过) npx create-react-app xxx xxx是自己自定义文件夹名称 ``` ## 2.打开服务器: yarn start 或者 npm start ![](https://box.kancloud.cn/e6a659fefd12ddd6227335fbc47e3ce2_338x157.png) # 跑一个helloworld ## 整理目录至如图 ![](https://box.kancloud.cn/87c0127df7e89a496b189c62308ac657_251x332.PNG) ##index.js ``` import React from 'react'; import ReactDOM from 'react-dom'; import App from './pages/App'; ReactDOM.render(<App />, document.getElementById('root')) ``` ## app.js ``` import React, { Component } from 'react'; class App extends Component { constructor(props){ super(props); this.state={ msg:"hello world" } } render() { return ( <div className="App"> hello world </div> ); } /* jsx */ render() { return ( <div onClick={this.handleclick.bind(this)}> {this.state.msg} </div> ) } handleclick() { this.setState({ msg: "change" }) } } export default App; ```