首页 > 解决方案 > 为什么 prettier.semi 不在我的 JavaScript 文件中添加任何分号?

问题描述

这是我的一个更漂亮的文件,没有添加任何分号,但格式很好,

function usercreate(name,score){
        this.name = name 
        this.score = score
        }
        usercreate.prototype.increment=function(){
            this.score++
            console.log(this.score)
        }
        usercreate.prototype.login=function(){
            console.log("loged in")
        }
    const user1=new usercreate("zahal",100)
    user1.increment()
    user1.login()
    const user2=new usercreate("sam",01)
    user2.increment()
    user2.login()

这是我的 v-code setting.json

{
    "workbench.colorTheme": "Visual Studio Light",
    "security.workspace.trust.untrustedFiles": "open",
    "prettier.semi": true
}

而且我不使用 Eslint

标签: javascriptprettier

解决方案


在对 Prettier 停止在 VSCode 中工作感到非常沮丧之后,我是如何对其进行排序的。

  1. 选择VS Code-> View-> Command Palette,然后输入:Format Document With
  2. 然后Configure Default Formatter……然后选择Prettier - Code formatter

这神奇地为我解决了问题。

根据您的情况,这可能会帮助您...


推荐阅读