React native 要使autocomplete在Visual Studio代码中为React Native工作,需要采取哪些步骤?
我遵循了VS代码文档中概述的步骤,通过为React-Native安装打字,让Intellisense为React-Native工作。现在,我需要做什么才能让自动完成工作?例如,如果我键入React native 要使autocomplete在Visual Studio代码中为React Native工作,需要采取哪些步骤?,react-native,visual-studio-code,React Native,Visual Studio Code,我遵循了VS代码文档中概述的步骤,通过为React-Native安装打字,让Intellisense为React-Native工作。现在,我需要做什么才能让自动完成工作?例如,如果我键入,我希望看到该标记自动关闭。我错过了什么?这似乎是开箱即用。要启用IntelliSense(自动完成),您必须安装官方扩展 安装 { "compilerOptions": { "allowSyntheticDefaultImports": true }, "exclude"
,我希望看到该标记自动关闭。我错过了什么?这似乎是开箱即用。要启用IntelliSense(自动完成),您必须安装官方扩展
安装
{
"compilerOptions": {
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules"
]
}
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules"
]
}
按F1打开命令选项板,键入ext install
并按Enter键,然后查找React Native Tools扩展
创建一个jsconfig.json文件
您应该在根目录中创建一个jsconfig.json
文件。它可以是空的,但必须存在。目录中存在这样一个文件表示该目录是JavaScript项目的根目录
(可选)
文件本身可以选择列出属于项目的文件、要从项目中排除的文件以及编译器选项
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules"
]
}
你可以在
为ReactNative Packger transformer创建一个.babelrc文件(如果要使用TypeScript,可选择)
您应该创建一个.babelrc
文件,其中包含sourceMaps=true
和预设“:[“react native”]
,以获得更好的源映射支持。(如果需要TypeScript支持,则为必填项)
为React Native安装打字功能(可选)
要获取React Native的IntelliSense,请在终端中运行npm install typings-g
,然后运行typings install dt~React Native--global
希望这有帮助
React-Native-Tools
在VSCode中无法帮助您在键入
后关闭标记,您可以尝试安装并在我的情况下,我必须将jsconfig.json复制到tsconfig.json,关闭可视代码并重新打开它。然后它就正常工作了
jsconfig.json
{
"compilerOptions": {
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules"
]
}
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules"
]
}
tsconfig.json
{
"compilerOptions": {
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules"
]
}
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules"
]
}
我也没有得到任何智能感知和包自动导入也不工作。因为我没有使用Typescript,所以删除
tsconfig.json
对我有帮助
首先备份您的
tsconfig.json
文件安装自动关闭标记扩展对我有用有没有办法为scr
中的所有文件以及节点单元中安装的依赖项启用自动完成功能?