JSX or HTML autocompletion in Visual Studio Code

前端 未结 16 1124
说谎
说谎 2020-12-12 10:14

Is there any way to use components or HTML completion in Visual Studio Code? Because typing each letter manually is not good idea when we have classes like Bootstrap etc. Fo

相关标签:
16条回答
  • 2020-12-12 11:07

    Just select the appropriate Language mode at the bottom-right on the screen: set it to JavaScript React.

    0 讨论(0)
  • 2020-12-12 11:08

    2018

    I'm using VSCode (ver 1.27.2)

    Base on my experienced, even though I'm working with React . The detected language on my VSCode is still vanilla JavaScript. And emmet did not work.

    • One of the ways to make it work again is change the VSCode detected language to JavaScript React. This is for single JS file only.

    • To change it once entirely, you need to associate it.

    Click Configure File Association for .js...

    And select JSX , which in my case, I already did.

    • For Workplace Setting, and last if none of them work for you. Go to Preference of just to ctrl + , (comma) to open it.

    Type and search for emmet or Emmet. Then copy the Setting you want to override. In my case:

    {
        "emmet.triggerExpansionOnTab": true,
        "emmet.includeLanguages": {
            "javascript": "javascriptreact"
        },
    }
    

    Note: I didn't try to use jsx only javascriptreact.

    I implemented the second and third step. And I can now do Emmet.

    0 讨论(0)
  • 2020-12-12 11:10

    None of those solutions worked... but the Auto Close Tag extension does! https://marketplace.visualstudio.com/items?itemName=formulahendry.auto-close-tag

    0 讨论(0)
  • 2020-12-12 11:14

    Only work in JSX files. Let it not work with JS.

    "files.associations": {
    "*.js": "javascript",
    "*.jsx": "javascriptreact",
    },
    "emmet.triggerExpansionOnTab": true,
    "emmet.includeLanguages": {
        "javascriptreact": "javascriptreact"
    },
    
    0 讨论(0)
提交回复
热议问题