简体   繁体   English

如何在 vs 代码中更新我的配置文件?

[英]How do I update my config file in vs code?

When I see example config files on VS Code they are often lengthy and offer two panels for updating (one for default settings and the other for customization).当我在 VS Code 上看到示例配置文件时,它们通常很长,并提供两个更新面板(一个用于默认设置,另一个用于自定义)。 For some reason my config file is only a few lines and whenever I try to update it, nothing happens:出于某种原因,我的配置文件只有几行,每当我尝试更新它时,什么也没有发生:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [

        {
            "type": "chrome",
            "request": "launch",
            "name": "Launch Chrome against localhost",
            "url": "http://localhost:3000",
            "webRoot": "${workspaceFolder}"
        }
    ]
}

For example I'm trying add a line of code to get rid of the error displayed for using .jsx in a .js file as found here and here but it doesn't work.例如,我正在尝试添加一行代码以消除在 .js 文件中使用 .jsx 显示的错误,如此此处所示,但它不起作用。 This is just an example, I've tried other modifications as well.这只是一个例子,我也尝试过其他修改。 How do I add the below code my launch.json (and is there more than one launch.json?).我如何将下面的代码添加到我的 launch.json(是否有多个 launch.json?)。 As you can see, I'm super new to this so thanks for any help.如您所见,我对此非常陌生,因此感谢您的帮助。

"rules": {
  "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
}

You can open:您可以打开:

  • default settings: Ctrl + Shift + P / Cmd + Shift + P -> Open Default Settings (JSON).默认设置: Ctrl + Shift + P / Cmd + Shift + P -> 打开默认设置 (JSON)。
  • VS Code setting (applied to whole VS code instance): Ctrl + Shift + P / Cmd + Shift + P ` -> Open Settings (JSON). VS Code 设置(适用于整个 VS 代码实例): Ctrl + Shift + P / Cmd + Shift + P ` -> 打开设置 (JSON)。
  • workspace settings (applied only to current "project"/folder): create in root directory '.vscode' folder -> 'settings.json' file.工作区设置(仅适用于当前“项目”/文件夹):在根目录 '.vscode' 文件夹中创建 -> 'settings.json' 文件。

All these you can find in UI instead of JSON.所有这些都可以在 UI 而不是 JSON 中找到。

In your example, you provided Launch configuration (it is not vs code settings), it is used to configure how to launch/debug your application.在您的示例中,您提供了 Launch 配置(它不是 vs 代码设置),它用于配置如何启动/调试您的应用程序。

And if you want to get rid of errors, you don't need to use VS Code settings.如果你想摆脱错误,你不需要使用 VS Code 设置。 These rules:这些规则:

"rules": { "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }], } "rules": { "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }], }

are configuration for eslint plugin (based on links you provided).是 eslint 插件的配置(基于您提供的链接)。 So, you need to place these lines to .eslintrc file and eslint and appropriate plugins should be installed and properly configured.因此,您需要将这些行.eslintrc文件中,并且应该安装并正确配置 eslint 和适当的插件。

The launch.json file is used for launching commands like building, running or debugging, you need to change some settings, not launching any thing. launch.json 文件用于启动构建、运行或调试等命令,您需要更改一些设置,而不是启动任何东西。 vsCode offers you couple of ways to declare your settings: vsCode 为您提供了几种声明设置的方法:

  1. Workspace - will save a settings.json file on your root workspace dir.工作区 - 将在您的根工作区目录中保存 settings.json 文件。
  2. User - will save a settings.json file on one of those pathes (according your os):用户 - 将在这些路径之一上保存 settings.json 文件(根据您的操作系统):
    1. Windows %APPDATA%\\Code\\User\\settings. Windows %APPDATA%\\代码\\用户\\设置。 json. json。
    2. Mac $HOME/Library/Application Support/Code/User/settings. Mac $HOME/Library/Application Support/Code/User/settings。 json. json。
    3. Linux $HOME/. Linux $HOME/. config/Code/User/settings.配置/代码/用户/设置。 json. json。

On vsCode docs you can read all about it.在 vsCode 文档上,您可以阅读所有相关内容。

You can edit your settings by ctrl + shift + p to open the command palette and search settings, or File > Preferences > Settings (Code > Preferences > Settings on Mac).您可以通过ctrl + shift + p打开命令面板和搜索设置,或通过文件 > 首选项 > 设置(Mac 上的代码 > 首选项 > 设置)编辑您的设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何模拟我的配置文件进行测试? - How do I mock my config file for testing? 更新依赖项后,如何让我的 Visual Studio Code IDE 更新类型? - How do I get my Visual Studio Code IDE to update the types after I update a dependency? 如何阻止 VS Code 在保存时完全破坏我的代码? - How do I stop VS Code from totally destroying my code on save? 如何在服务人员中获取我的配置 json 文件 - How do I fetch my config json file inside service worker 如何强制更新我的反应代码中的组件以将深色主题切换为浅色主题 - How do I force Update my components in my react code to toggle dark theme to light theme 如何在用 TypeScript 编写的 VS Code 扩展中导入 ES6 JavaScript 模块? - How do I import an ES6 JavaScript module in my VS Code extension written in TypeScript? 如何阻止我的 vs 代码应用程序显示错误弹出消息 - How do i stop my vs code app from displaying the error pop up message 如何更新我在PrimeFaces commandButton组件的oncomplete事件中使用的javascript代码 - How do I update my javascript code that I used on oncomplete event of PrimeFaces commandButton component 如何配置 html 输入验证码? - How do I config html input for verification code? 如何将调试添加到我的 webpack 配置中 - how do I add debug to my webpack config
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM