簡體   English   中英

Sublime Text Emmet JSX selfClosingStyle

[英]Sublime Text Emmet JSX selfClosingStyle

您好,我將最新的 Sublime Text 4 與 Emmet 和 reactjs 源代碼一起使用,並在Syntax -> Javasript > JSX中構建,它可以正常工作。

我將默認的 emmet 設置"jsx_prefix": true,更改為 false,它起作用了——現在我可以在沒有<的情況下擴展標簽。

但我想更改默認擴展Component/ -> <Component><Component />

我嘗試將"markup_style": "html",更改為 xhtml 或 xml 但它不起作用。

在 emmet 設置中我可以看到這個參數,這也許可以解決我的問題:

    // See `GlobalConfig` interface for supported properties: https://github.com/emmetio/emmet/blob/master/src/config.ts
    // Example:
    // "config": {
    //  "markup": {
    //      "snippets": {
    //          "foo": "foo.bar>baz"
    //      },
    //      "options": {
    //          "output.selfClosingStyle": "xhtml"
    //      }
    //  }
    // }
    "config": {},

因為我不了解 TS,所以我無法閱讀 GitHub 中的源代碼來解決這個問題,誰能知道如何使用此config參數而不是像示例中的一個片段,而是用於帶有"output.selfClosingStyle": "xhtml"

我嘗試寫這樣的東西(但不起作用):

"config": {
        "markup": "jsx",
        "options": {
            "output.selfClosingStyle": "xhtml"
        }
    }

請幫助我在 ST4 中使用帶有 emmet 的 JSX 自閉標簽。

在 Sublime Text 中,您可以為語法類型( markupstylesheet )或特定語法全局指定配置。

語法在 Emmet 配置的syntax_scopes選項中列出,它是語法名稱到 Sublime Text 內部 scope 的映射(您也可以像這樣創建自己的語法)。

在您的情況下,您應該為jsx語法指定配置,如下所示:

{
    "config": {
        "jsx": {
            "options": {
                "output.selfClosingStyle": "xhtml"
            }   
        }
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM