react-nativeReact Native

Sublime Text 3开发ReactNative的一些插件

2016-05-11  本文已影响4065人  iwgang

前期准备

注:先检查是否已经安装好了Package Control,如果已经安装好了就无需重复安装
如果在菜单Preferences下面有Package Control则表示已经安装过了

View->Show Console菜单打开命令行,粘贴如下代码:

import urllib.request,os,hashlib; h = '2915d1851351e5ee549c20394736b442' + '8bc59f460fa1548d1514676163dafc88'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)

安装后好,打开Package Control(Preferences -> Package Control)输入install,然后再输入想要安装的插件名称就可以安装插件了

1. ReactJS
支持React.js代码提示,高亮显示等...
官网:https://github.com/facebookarchive/sublime-react
效果图:

reactjs.gif

**2. Emmet **
使用仿CSS选择器的语法来生成代码,大大提高了HTML/CSS代码编写的速度
官网:https://github.com/sergeche/emmet-sublime
效果图:

1.gif
配置:
a). 修改 Emmet 兼容jsx 文件
菜单 preferences -> Key bindings - Users,把下面代码复制到[]内部
    {
      "keys": [
        "super+e"
      ],
      "args": {
        "action": "expand_abbreviation"
      },
      "command": "run_emmet_action",
      "context": [{
        "key": "emmet_action_enabled.expand_abbreviation"
      }]
    },
    {
      "keys": ["tab"],
      "command": "expand_abbreviation_by_tab",
      "context": [{
        "operand": "source.js",
        "operator": "equal",
        "match_all": true,
        "key": "selector"
      }, {
        "key": "preceding_text",
        "operator": "regex_contains",
        "operand": "(\\b(a\\b|div|span|p\\b|button)(\\.\\w*|>\\w*)?([^}]*?}$)?)",
        "match_all": true
      }, {
        "key": "selection_empty",
        "operator": "equal",
        "operand": true,
        "match_all": true
      }]
    }

使用super+e 触发 emmet;正则判断用 a,div,span,p,button标签默认tab 触发;默认 class 修改为 className
注:supre+e 在 PC 上指的是win+e (pc 建议修改为emmet 默认按键 ctrl+e),在 mac 上指的是cmd+e

3. babel-sublime
支持ES6, React.js, jsx代码高亮
官网:https://github.com/babel/babel-sublime
配置:
打开.js, .jsx 后缀的文件后,点击菜单View -> Syntax -> Open all with current extension as... -> Babel -> JavaScript (Babel),即可设置babel为默认 javascript 打开syntax

4. react-native-snippets
提供了一些react-native的代码快速构建模板
官网:https://github.com/Shrugs/react-native-snippets

5. JsFormat
js格式化
官网:https://github.com/jdc0589/JsFormat
配置:
a). 让其支持JSX
菜单 preferences -> Package Settings -> JsFormat -> Setting - Users,输入以下代码:

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

6. Terminal
快速打开终端并定位到当前项目所在目录
官网:https://github.com/wbond/sublime_terminal

参考:
https://segmentfault.com/a/1190000003698071
http://www.jianshu.com/p/2ddfff095e90

上一篇 下一篇

猜你喜欢

热点阅读