Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio code VSCode Prettier扩展与命令行Prettier_Visual Studio Code_Prettier - Fatal编程技术网

Visual studio code VSCode Prettier扩展与命令行Prettier

Visual studio code VSCode Prettier扩展与命令行Prettier,visual-studio-code,prettier,Visual Studio Code,Prettier,我有一个问题,在使用命令行时,VSCode中的HTML文件格式“on save”与Prettier的格式不同 我的用户设置(更改这些值似乎没有任何区别): 当我从命令行运行Prettier时,我的HTML格式如下: prettier --write "./src/app/my-file.html" my-file.html: <a ng-hide="$last" href="" ng-click="doThis(thi

我有一个问题,在使用命令行时,VSCode中的HTML文件格式“on save”与Prettier的格式不同

我的用户设置(更改这些值似乎没有任何区别):

当我从命令行运行Prettier时,我的HTML格式如下:

prettier --write "./src/app/my-file.html"
my-file.html:

<a ng-hide="$last" href="" ng-click="doThis(thing)"
  >{{ crumb.title }}</a
>

我知道扩展已安装并正在工作,因为我在屏幕右下角看到此图标:

当我将鼠标悬停在这个图标上时,我会看到一个工具提示,上面写着
prettier@1.16.3
,与我在命令行上安装的版本相同
prettier-v


为什么我用这两种方法得到不同的结果?除上述设置外,我没有更改任何设置。我需要创建一个包含以下内容的
.prettierrc
文件:

{
  "overrides": [
    {
      "files": "*.html",
      "options": {
        "parser": "html"
      }
    }
  ]
}

命令行使用
html
解析器,而VSCode使用
angular
解析器。通过这种方式,他们对
.html
文件使用相同的解析器。

祝福您找到这个!好几天来我一直在用头撞这个。我的
prettier-检查。
prettier-写入。
与插件冲突。感谢您抽出时间回答您自己的问题,这很有帮助!
<a ng-hide="$last" href="" ng-click="doThis(thing)">{{
  crumb.title
}}</a>
{
  "overrides": [
    {
      "files": "*.html",
      "options": {
        "parser": "html"
      }
    }
  ]
}