sublime3 支持jsx es6語法


Sublime Text3 React.js開發常用插件

本文主要是針對jsx語法的,用來快速編寫組件中的html部分。

babel

支持ES6、React.js、jsx代碼語法高亮。

安裝

command+shift+p -> install package -> babel

配置

該插件不需要額外配置,在打開.js.jsx后綴的文件,直接選擇Babel為對應的語法就可以了。

Emmet

可以自動擴展react的className,這點不要太爽~
我們要做的,只是安裝好它之后稍微做下配置修改,就可以愉快的開擼了。

安裝

command+shift+p -> install package -> emmet

配置

打開菜單Preferences -> Package Settings -> Emmet -> Key Bindings - User

將下面代碼貼進去保存。更詳細的規則可以參考emmet-sublime文檔

[{
    "keys": ["tab"],
    "command": "expand_abbreviation_by_tab",

    // put comma-separated syntax selectors for which 
    // you want to expandEmmet abbreviations into "operand" key 
    // instead of SCOPE_SELECTOR.
    // Examples: source.js, text.html - source
    "context": [{
            "operand": "source.js",
            "operator": "equal",
            "match_all": true,
            "key": "selector"
        },

        // run only if there's no selected text
        {
            "match_all": true,
            "key": "selection_empty"
        },

        // don't work if there are active tabstops
        {
            "operator": "equal",
            "operand": false,
            "match_all": true,
            "key": "has_next_field"
        },

        // don't work if completion popup is visible and you
        // want to insert completion with Tab. If you want to
        // expand Emmet with Tab even if popup is visible -- 
        // remove this section
        {
            "operand": false,
            "operator": "equal",
            "match_all": true,
            "key": "auto_complete_visible"
        }, {
            "match_all": true,
            "key": "is_abbreviation"
        }
    ]
}]

 

jsformat

jsformat是sublime上js格式化比較好用的插件之一,通過修改它的e4x屬性可以使它支持jsx

安裝

command+shift+p -> install package -> jsformat

配置

打開菜單Preferences -> Package Settings -> JsFormat -> Settings - User,將下面代碼貼進去保存。

{
  "e4x": true,
  // jsformat options
  "format_on_save": true,
}

 

 

 
 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM