win7下的Sublime Text3 运行ES6方法

其实非常简单,配置个编译系统即可。

下载 nodejs

这个网上很多教程的,就不讲了。

安装Babel

$ npm install -g babel

在ST新建编译系统

选择菜单 Tools –> Build System –> new Build System…
中文版的话是 工具 –> 编译系统 –> 新建编译系统…

{
    "working_dir": "${project_path:${folder}}",
    "selector": "source.js",
    "encoding": "utf-8",
    "shell": true,
    "windows": {
        "cmd": ["node", "$file"]
    },
    "osx": {
        "cmd": ["killall node >/dev/null 2>&1; babel-node $file"]
    },
    "linux": {
        "cmd": ["killall node >/dev/null 2>&1; babel-node $file"]
    }
}

保存为 javascript.sublime-build,保存位置默认即可。
现在,我们在桌面新建一个 test.js 试试吧,写个简单的测试代码后按 Ctrl + B 或者 F7 运行。

转自 http://www.tuicool.com/articl…

    原文作者:dada86
    原文地址: https://segmentfault.com/a/1190000008638805
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞