小编vyt*_*ute的帖子

在 Visual Studio Code 中找不到自动修复保存按钮

我正在按照教程打开保存文件时的 ESLint 自动修复。教程演示了如何选中复选框。我找不到它。我需要任何扩展或 smth 吗?

转到:查看 -> 命令面板 -> 首选项:打开工作区设置 -> 扩展 -> ESLint

这是教程中设置页面的样子:

设置页面的外观

这就是我所看到的:

这是我看到的

eslint visual-studio-code

15
推荐指数
2
解决办法
8798
查看次数

Visual Studio 2017 中的 Windows Forms Application menuStrip 比 2019 更方便?

我正在尝试创建 Windows 窗体应用程序并将 menuStrip 项添加到我的设计器窗口。在 VS 2017 中,您只需单击 menuStrip 并添加项目,但在 VS 2019 中,您必须通过属性 -> 数据 -> 项目手动添加所有项目。我对吗?或者我应该打开一些属性来回到 2017 年添加元素的风格?

VS 2017 menuStrip 设计:

VS 2017 menuStrip 设计

VS 2019 menuStrip 设计(太不舒服了!): 在此处输入图片说明

那么我可以做些什么来恢复到 2017 年那种方便的编辑状态吗?

c# user-interface winforms visual-studio-2017 visual-studio-2019

7
推荐指数
1
解决办法
2457
查看次数

ESLint 不格式化

我有一个简单的项目,只有几个 html 和 js 文件。为 VS 代码安装 ESLint 扩展并将 ESLint 设置为默认格式化程序:

环境

此外,此设置已转向所有

设置2

这是我的 settings.json 文件:

 "window.zoomLevel": 1,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
"eslint.validate": ["javascript"],
  "git.enableSmartCommit": true,
  "eslint.alwaysShowStatus": true,
  "files.autoSave": "off",
  "editor.formatOnSave": true,
  "editor.formatOnPaste": true,
  "editor.formatOnType": true,
  "git.ignoreWindowsGit27Warning": true,
  "eslint.options": {
    "eslint brace-style": [
      "error",
      "allman",
      {
        "allowSingleLine": true
      }
    ]
  },
  "eslint.codeAction.showDocumentation": {

    "enable": true
  },
  "editor.defaultFormatter": "dbaeumer.vscode-eslint",
  "eslint.format.enable": true
}
Run Code Online (Sandbox Code Playgroud)

当按下保存 ESLint 对我的 js 文件不起作用(没有括号、空格等被更正)。我之前在 React 应用程序中使用过 ESLint,所以它在一年前就成功了。

formatting eslint visual-studio-code

6
推荐指数
1
解决办法
7557
查看次数

行结尾不遵循 VS Code 中的默认设置

当我尝试推送到 GitHub 时,每次我都会收到这样的警告:

warning: LF will be replaced by CRLF in app/bingey-api/models/user.js.
The file will have its original line endings in your working directory
Run Code Online (Sandbox Code Playgroud)

即使我在这些地方将行结尾设置更改为“/n”:

用户 -> 文本编辑器 -> 文件 -> Eol:

在此输入图像描述

另外,工作区 -> 文本编辑器 -> 文件 -> Eol:

在此输入图像描述

我的 ESLint 选项文件也有默认行结尾“\n”:

在此输入图像描述

Prettier 也配置为默认的“\n”结束符:

在此输入图像描述

这很奇怪,也许有人知道我还应该在哪里更改设置?谢谢。

formatting line-endings eol visual-studio-code

5
推荐指数
1
解决办法
3422
查看次数

自动保存在VS代码中Python的注释和函数头之间添加两个空行

我在 VS Code 中用 Python 编写代码。如果我在函数之前添加注释并点击保存按钮,VS code 将添加两个空行:

# comment


def MyMethod():
    return 0
Run Code Online (Sandbox Code Playgroud)

在设置中我看到我使用 autopep8 格式化程序: autopep8 格式化程序

我无法找到导致这个恼人问题的原因。也许我可以在某处配置设置?

python formatting visual-studio-code pylance

5
推荐指数
1
解决办法
1982
查看次数

在 React 中动态添加后的 getElementById

我正在我的 React 功能组件中动态添加卡片。卡片存储在状态中。我映射它们并给每个人提供 id。OnClick 在那些卡片上我成功地获得了他们的 id。现在我想 getElementById 来改变卡片颜色:

function Clicked(pressedGifId) {
  if (pressedGifId === 'correctGif') CorrectMatch();
  else WrongMatch();
}

function CorrectMatch(pressedGifId) {
  // / THERE I GET Element: null
  console.log('Element:', document.getElementById(pressedGifId));
}
function WrongMatch() {
  console.log('wrong a match!');
}

export default function GameObject(props) {
  const addedToGameGif = [];
  const [pressedGifId, gifPressed] = useState(null);
  const [photoCards, setPhotoCards] = useState([]);

  useEffect(() => {
    Clicked(pressedGifId);
  }, [pressedGifId]);

  // add randomly picked photos to addedToGameGif array
  // ...

  addedToGameGif.map(gifId =>
    photoCards.push(
      <Card id={gifId} onClick={() …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs use-effect use-state use-ref

2
推荐指数
1
解决办法
4771
查看次数

Google API REST 调用仅返回用户 ID 和图片。如何使用 Google API REST 请求获取完整的用户信息?

我尝试通过 API 请求访问 Google 用户信息;

 https://www.googleapis.com/oauth2/v1/userinfo?access_token=ya29.a0Ael9sCMYNzgxZT27Cb....
Run Code Online (Sandbox Code Playgroud)

我得到的回复只是 ID 和个人资料图片:

{
    "id": "1.....",
    "picture": "https://lh3.googleusercontent.com/a-/ACB-R5Sg...."
}
Run Code Online (Sandbox Code Playgroud)

我需要更多用户信息:电子邮件、姓名等。

我已在开发人员控制台中添加了 user.profile 和 userinfo.email 以及 userinfo.profile 范围。

添加范围

我知道添加的范围可能需要 5 分钟甚至几个小时才能工作,但我在大约 12 小时前添加了它。

如何修复我的 API REST 调用以从 Google API 获取更多用户信息?

编辑

这个问题是相同的,但答案对我不起作用。这个请求:

https://people.googleapis.com/v1/people/me?personFields=names,emailAddresses&access_token=ya29.a0...&key=498...apps.googleusercontent.com
Run Code Online (Sandbox Code Playgroud)

给我带来了Request had insufficient authentication scopes错误。

也许我在那里提供了错误的密钥?那么 api 密钥应该是什么,它来自凭证页面的客户端 ID 吗?

api rest google-api access-token google-oauth

2
推荐指数
1
解决办法
1134
查看次数