vscode react-native

vscode

  1. 使用react-native init --version=”0.55.4” WangZg 工程后,使用vscode 打开文件夹,指定WangZg文件夹,就打开了WangZg工程
  2. Vscode发现检查错误

File-perference-settings --workspace settings

Settings.json中,增加 "javascript.validate.enable": false   (这个是不启用检查)

2.2)yarn add husky lint-staged prettier

需要先安装yarn,然后重启电脑,原因是增加了环境变量

然后在package.json的第一个{}中最后增加 "precommit": "lint-staged"

然后增加一个json

"lint-staged": {

    "src/**/*.{js,jsx,json,css}": [

      "prettier --single-quote --write",

      "git add"

    ]

   }

2.3)安装prettier flow  eslint ,格式化代码

2.4)https://github.com/prettier/eslint-config-prettier

新建一个.eclintrc.json文件,文件中内容

{

  "extends": [

    "standard",

    "plugin:flowtype/recommended",

    "plugin:react/recommended",

    "prettier",

    "prettier/flowtype",

    "prettier/react",

    "prettier/standard"

  ],

  "plugins": [

    "flowtype",

    "react",

    "prettier",

    "standard"

  ],

  "parserOptions": {

    "sourceType": "module",

    "ecmaFeatures": {

      "jsx": true

    }

  },

  "env": {

    "es6": true,

    "node": true

  },

  "rules": {

    "prettier/prettier": "error"

  }

}

2.5)重启vscode,安装 eslint

yarn add eslint --dev

2.6)新建.prettierrc

{

    "printWidth": 100,

    "semi": false,

    "singleQuote": true

}

3)使用vscode 进行调试

3.1)vscode安装 react native tools

3.2)使用react native tools调试

在debug android 下面有个配置项,选择那个配置,可以在右边弹出很多项,选择react native:debug   android

然后点击三角按钮,进行调试运行

 

  1. 在安装各个插件的时候,我们㤇知道安装好了没有,可以点击输出,在右边的任务有个下来列表,选择对应的任务,就可以知道了,我在安装eslint的时候,看到有很多错误,基本上都是没有安装插件的原因 yarn add pluginname --dev  安装,安装一个重启一次vscode,然后看输出任务,就能知道安装好了没有,接着安装

 

 

 

 

在VScode debug调试出现Could not debug. Unknown error: not all success patterns were matched.

It means that "react-native run-android" command failed. Please, check the View -> Toggle Output -> React-native, View -> Toggle Output -> React-native: Run android output windows.

是什么问题?

原因是没有启动虚拟机。

使用的参考文章

https://blog.csdn.net/guoer9973/article/details/54669885

https://www.bilibili.com/video/av17087983/

https://blog.csdn.net/young_emily/article/details/79005728

猜你喜欢

转载自blog.csdn.net/fivestar2009/article/details/81263595