1. 程式人生 > >使用VSCode編輯器建立React.js專案

使用VSCode編輯器建立React.js專案

一、環境準備:
1、下載安裝VSCode,Node.js,Yarn
2、開啟命令列終端或powershell,輸入yarn global add create-react-app安裝react的腳手架create-react-app
3、開啟VSCode,安裝相應外掛
必要:ESLint、DocumentThis、EasyLess、Complete JSDoc Tags、vscode-flow-ide、React native Tools、vscode-wechat、npm、babel-javascript、debugger for chrome、git lens、node debug 2、
可選:javascript (ES6) code snippets、reactjs code snippets、react-native/react/redux snippets for es6/es7、highlight bad chars、color highlight、Path Intellisense、partial diff

二、新建demo
1、VSCode編輯器中使用快捷鍵ctrl+`開啟終端
2、在終端輸入create-react-app demo,自動建立名稱為demo的專案
3、cd demo進入demo專案中
4、yarn start或yarn build執行專案

三、react專案中使用echarts
1、終端輸入命令yarn add echarts 引入echarts
2、在需要使用echarts的js檔案中,引入echarts模組,具體有哪些可以按需引入的模組列表可檢視demo->node_modules->echarts->index.js檔案

// 引入 ECharts 主模組
import echarts from 'echarts/lib/echarts'; import 'echarts/lib/chart/line'; // 引入柱狀圖 import 'echarts/lib/chart/bar'; // 引入提示框和標題元件 import 'echarts/lib/component/tooltip'; import 'echarts/lib/component/title';

四、快捷鍵
終端使用ctrl+c退出批處理操作