2016-08-05 64 views

回答

3

要启用智能感知(自动完成),您必须安装官方React Native Tools扩展。

安装

打开命令面板按F1,类型ext install,然后按Enter键,然后寻找阵营本地工具扩展。

创建jsconfig.json文件

您应该创建一个jsconfig.json文件在你的根目录。它可以是空的,但必须存在。目录中存在这样的文件表明该目录是JavaScript项目的根目录。

可选

文件本身可以选择性地列出属于该项目中的文件,这些文件将被排除在项目,以及编译器选项。

{ 
    "compilerOptions": { 
    "target": "ES6", 
    "module": "commonjs", 
    "allowSyntheticDefaultImports": true 
    }, 
    "exclude": [ 
    "node_modules" 
    ] 
} 

你可以找到更多在https://code.visualstudio.com/docs/languages/javascript#_javascript-projects-jsconfigjson

创建ReactNative Packger变压器一个.babelrc文件(可选的,如果你想使用打字稿

您应该创建一个.babelrc文件与sourceMaps = true"presets": [ "react-native" ]为更好的源映射支持。 (如果您需要TypeScript支持,则需要)。

{ 
    "presets": [ 
    "react-native" // this is required for debugging with react-native/packager/transformer 
    ], 
    "plugins": [], 
    "sourceMaps": true // must be true react-native/packager/transformer using with node-module-debug 
    // because of some bugs from vscode-node-debug & vscode-react-native, "sourceMaps" cannot be "inline" or "both" 
} 

安装分型的阵营本地可选

要获取本机作出反应,运行npm install typings -g和智能感知,然后在你的终端typings install dt~react-native --global

希望这有助于!

在VSCode
0

就我而言,我不得不jsconfig.json复制到tsconfig.json,关闭Visual代码并重新打开它。然后它正常工作。

jsconfig。JSON

{ 
    "compilerOptions": { 
     "allowSyntheticDefaultImports": true 
    }, 
    "exclude": [ 
     "node_modules" 
    ] 
} 

tsconfig.json

{ 
    "compilerOptions": { 
     "allowJs": true, 
     "allowSyntheticDefaultImports": true 
    }, 
    "exclude": [ 
     "node_modules" 
    ] 
} 
相关问题