????在進行React開發(fā)的過程中,React提供了官方的瀏覽器擴展插件React Devtools調(diào)試工具,其下載地址是https://fb.me/react-devtools,但由于某些原因,前面的下載鏈接我自始至終都沒有打開過,所以只能另想辦法了。
1、從GitHub中將react-devtools項目源代碼拷貝到本地
git clone git@github.com:facebook/react-devtools.git
2、安裝項目依賴
npm install
3、查找項目命令
從Package.json文件中的Script下查找以下命令:
"scripts": {
"build:extension": "yarn run build:extension:chrome && yarn run build:extension:firefox",
"build:extension:chrome": "node ./shells/chrome/build",
"build:extension:firefox": "node ./shells/firefox/build"
}
4、打包項目,生成擴展程序
這里以Chrome瀏覽器為例:
npm run build:extension:chrome
將會在項目目錄下,生成一個shells/chrome/build/unpacked目錄,這就是擴展程序的部署包,將其拷貝到容易找到的地方。
5、將擴展程序安裝到瀏覽器中,并開始React調(diào)試
從瀏覽器中地址欄中打開地址chrome://extensions/,點擊“加載已解壓的擴展程序”加載完成之后,即安裝成功。
6、注意事項
千萬不要刪除正在加載使用的shells/chrome/build/unpacked文件夾,否則需要重新安裝。