reactjs - react native 的自动导入在 vscode 上不起作用
问题描述
我正在开发一个反应本机应用程序,但无论我做什么,自动导入功能都不适用于 vscode。我想要的功能(如果你输入,它会自动从 React 导入 Text 模块)这就是现在发生的事情,这对我来说没有突出任何错误 我当前的问题截图
我已经寻找了一些类似的问题,但没有一个对我有帮助。我尝试修复我的 eslint 并添加了 jsconfig,但它不起作用。任何建议将不胜感激。
eslint.js:
module.exports = {
extends: "airbnb",
plugins: ["react", "react-native", "react-hooks"],
parser: "babel-eslint",
env: {
jest: true,
"react-native/react-native": true,
},
rules: {
"no-use-before-define": "off",
"react/jsx-filename-extension": "off",
"react/prop-types": "off",
"comma-dangle": "off",
"padded-blocks": "off",
"arrow-body-style": "off",
"react-hooks/exhaustive-deps": "warn",
"react-native/no-unused-styles": 2,
"react-native/split-platform-components": 2,
"react-native/no-inline-styles": 2,
"react-native/no-color-literals": 2,
"react-native/no-raw-text": 2,
"react-native/no-single-element-style-arrays": 2,
},
globals: {
fetch: false,
},
// Indent with 4 spaces
indent: ["error", 4],
// Indent JSX with 4 spaces
"react/jsx-indent": ["error", 4],
// Indent props with 4 spaces
"react/jsx-indent-props": ["error", 4],
};
包.json:
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject",
"lint": "eslint *.js **/*.js src/**/*.js"
},
"dependencies": {
"expo": "~40.0.0",
"expo-status-bar": "~1.0.3",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz",
"react-native-web": "~0.13.12"
},
"devDependencies": {
"@babel/core": "~7.9.0",
"babel-eslint": "^10.1.0",
"eslint": "^7.20.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.22.0",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-react-native": "^3.10.0"
},
"private": true
}
babel.config.js:
module.exports = function (api) {
api.cache(true);
return {
presets: ["babel-preset-expo"],
};
};
解决方案
推荐阅读
- javascript - 带有值的 Javascript 数组
- java - 编译时间与运行时间(通过查看代码)
- azure - ARM模板:如何以数组格式读取输出结果
- java - IO 错误:将 oracle DB 作为 docker 容器运行并尝试通过 Tomcat 连接时,网络适配器无法建立连接
- kubernetes - 无法使用 Istio 网关访问 Kubernetes 集群
- python - STAN RuntimeError:初始化失败
- python - 代替 。在 json 文件中使用 _ 并使用 python 将其写入表
- c# - 如何在 C# 中解密 EncryptedXml?
- java - 想在eclipse上使用我自己的控制台,但是遇到一些unkown error for package not found
- angular - 为什么我在间隔内更改对象引用并且更改检测为onPush时UI不更新?