{"id":21173959,"url":"https://github.com/huanghui8030/es6","last_synced_at":"2026-05-18T04:08:28.191Z","repository":{"id":5710557,"uuid":"6921555","full_name":"huanghui8030/ES6","owner":"huanghui8030","description":"ES学习","archived":false,"fork":false,"pushed_at":"2018-05-28T00:40:30.000Z","size":3978,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-26T15:53:43.994Z","etag":null,"topics":["babel","es6","javascript"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/huanghui8030.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-11-29T13:23:01.000Z","updated_at":"2018-05-28T00:40:32.000Z","dependencies_parsed_at":"2022-08-24T21:40:23.813Z","dependency_job_id":null,"html_url":"https://github.com/huanghui8030/ES6","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/huanghui8030/ES6","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huanghui8030%2FES6","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huanghui8030%2FES6/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huanghui8030%2FES6/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huanghui8030%2FES6/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/huanghui8030","download_url":"https://codeload.github.com/huanghui8030/ES6/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huanghui8030%2FES6/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279017787,"owners_count":26086144,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["babel","es6","javascript"],"created_at":"2024-11-20T16:52:50.927Z","updated_at":"2025-10-14T03:23:43.552Z","avatar_url":"https://github.com/huanghui8030.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ES6学习\n\nES6不是全面兼容，如果兼容，需要通过babel进行转译。\n\n\n## 介绍一下babel用法\n### 1、浏览器中的用法\n\n- 注意js中的type值必须写`text/babel`，代码如下：\n\n    ```html\n    \u003cdiv id=\"output\"\u003e\u003c/div\u003e\n    \u003cscript src=\"js/babel.min.js\"\u003e\u003c/script\u003e\n    \u003cscript type=\"text/babel\"\u003e\n      const getMessage = () =\u003e \"Hello World\";\n      document.getElementById('output').innerHTML = getMessage();\n    \u003c/script\u003e\n    ```\n\n- 浏览器访问效果：\n\n    ![效果图](images/0101.png)\n\n\u003e 详见[demo01](demo01/demo01.html)\n\n\n\n### 2、终端中的用法 Node\n\n- 安装两个插件，babel-cli 和babel-preset-env： `cnpm install --save-dev babel-cli babel-preset-env`\n\n- 新创建`.babelrc`文件，添加配置：\n\n    ```json\n    {\n        \"presets\": [\n          \"env\"\n        ]\n    }\n    ```\n\n- 在src目录下面新建一个a.js\n\n    ```js\n    const getMessage = () =\u003e \"Hello World\";\n    document.getElementById('output').innerHTML = getMessage();\n    ```\n\n- 可在`package.json`中添加快捷键`scripts` ：\n\n    ```json\n    {\n        \"scripts\": {\n            \"build\": \"babel src -d lib\"\n        },\n        \"devDependencies\": {\n            \"babel-cli\": \"^6.26.0\",\n            \"babel-preset-env\": \"^1.6.1\"\n        }\n    }\n    ```\n\n- 终端执行：`cnpm run build`\n\n    ![效果图](images/0201.png)\n\n- 如果不配置package.json，则执行命令为：`./node_modules/.bin/babel src -d lib` 。由于babel不是全局变量。\n\n    ![效果图](images/0202.png)\n\n- 生成文件`lib/a.js`，代码如下：\n\n    ```js\n    \"use strict\";\n    var getMessage = function getMessage() {\n      return \"Hello World\";\n    };\n    document.getElementById('output').innerHTML = getMessage();\n    ```\n\n- 目录结构以及效果如下：\n    ![效果图](images/0203.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuanghui8030%2Fes6","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuanghui8030%2Fes6","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuanghui8030%2Fes6/lists"}