漂亮的JS VSCode设置未按预期工作

问题描述

我已经安装了漂亮的文件,并且在我运行prettier --write .

时似乎可以从可执行文件中按预期工作

我正在尝试使用vscode插件将其设置为“保存时格式化” ...但这似乎无法正确格式化。我可以弄清楚是什么原因造成的。

给出以下代码(当我运行prettier --write .时,它不变):

import React from "react";

const TestComponent = ({ someVal = "hello world" }) => (
  <div>
    <span>{someVal}</span>
  </div>
);

如果我启用“保存时格式化”并保存文件,它将代码更改为:

import React from "react";

const TestComponent = ({
  someVal = "hello world"
}) => ( <
  div >
  <
  span > {
    someVal
  } < /span> <
  /div>
);

我的.prettierrc.json为空,如以下内容所述:https://prettier.io/docs/en/install.html

{}

其他人有没有经历过或知道如何解决

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)