fengchuanyu 8 月之前
父节点
当前提交
63d416e924

+ 47 - 0
.gitignore

@@ -0,0 +1,47 @@
+# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
+
+# dependencies
+**/node_modules
+# roadhog-api-doc ignore
+/src/utils/request-temp.js
+_roadhog-api-doc
+ant-pro
+
+# production
+/dist
+/.vscode
+
+# misc
+.DS_Store
+npm-debug.log*
+yarn-error.log
+
+/coverage
+.idea
+yarn.lock
+package-lock.json
+*bak
+.vscode
+
+# visual studio code
+.history
+*.log
+
+functions/mock
+.temp/**
+
+# umi
+.umi
+.umi-production
+
+# screenshot
+screenshot
+.firebase
+
+# mine
+testWebpack
+test
+笔记
+面试
+练习题
+测试代码

+ 3 - 0
5_ES6/babel/.babelrc

@@ -0,0 +1,3 @@
+{
+    "presets": ["env"]
+}

+ 15 - 0
5_ES6/babel/dist/export.js

@@ -0,0 +1,15 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+    value: true
+});
+// export let a = "hello";
+// export function foo(){
+//     return "你好"
+// }
+
+function foo4() {
+    return "一个函数";
+}
+
+exports.default = foo4;

+ 17 - 0
5_ES6/babel/dist/import.js

@@ -0,0 +1,17 @@
+"use strict";
+
+var _export = require("./export");
+
+var _export2 = _interopRequireDefault(_export);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+console.log((0, _export2.default)()); // import { a,foo as foo2 } from "./export";
+// let str = "world";
+// str += a;
+// function foo(){
+//     console.log("123");
+// }
+// foo();
+// console.log(str);
+// console.log(foo2());

+ 4 - 0
5_ES6/babel/dist/index.js

@@ -0,0 +1,4 @@
+"use strict";
+
+var a = 10;
+console.log(a);

+ 16 - 0
5_ES6/babel/package.json

@@ -0,0 +1,16 @@
+{
+  "name": "babel",
+  "version": "1.0.0",
+  "description": "",
+  "main": "index.js",
+  "scripts": {
+    "build":"babel src -d dist"
+  },
+  "keywords": [],
+  "author": "",
+  "license": "ISC",
+  "devDependencies": {
+    "babel-cli": "^6.26.0",
+    "babel-preset-env": "^1.7.0"
+  }
+}

+ 10 - 0
5_ES6/babel/src/export.js

@@ -0,0 +1,10 @@
+// export let a = "hello";
+// export function foo(){
+//     return "你好"
+// }
+
+function foo4(){
+    return "一个函数"
+}
+
+export default foo4

+ 12 - 0
5_ES6/babel/src/import.js

@@ -0,0 +1,12 @@
+// import { a,foo as foo2 } from "./export";
+// let str = "world";
+// str += a;
+// function foo(){
+//     console.log("123");
+// }
+// foo();
+// console.log(str);
+// console.log(foo2());
+
+import foo5 from "./export"
+console.log(foo5());

+ 2 - 0
5_ES6/babel/src/index.js

@@ -0,0 +1,2 @@
+let a = 10;
+console.log(a);

+ 106 - 0
5_ES6/练习题7讲解.html

@@ -0,0 +1,106 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+</head>
+
+<body>
+    <script>
+        // console.log('1');
+        // setTimeout(function () {
+        //     console.log('2');
+        // }, 0);
+        // console.log('3');
+        // 1
+        // 3
+        // 2
+
+        // console.log('1');
+        // setTimeout(function () {
+        //     console.log('2');
+        //     Promise.resolve().then(function () {
+        //         console.log('3');
+        //     });
+        // }, 0);
+        // Promise.resolve().then(function () {
+        //     console.log('4');
+        // });
+        // console.log('5');
+        // 1
+        // 5
+        // 4
+        // 2
+        // 3
+
+        // 同步任务,输出 '1'
+        // console.log('1');
+        // setTimeout(() => {
+        //     // 定时器回调函数,宏任务
+        //     console.log('2 - Macro Task');
+        //     // 添加一个微任务到队列中
+        //     Promise.resolve().then(() => console.log('3 - Micro Task'));
+        // }, 0);
+        // // 添加一个微任务到队列中
+        // Promise.resolve().then(() => console.log('4 - Micro Task'));
+        // // 同步任务,输出 '5'
+        // console.log('5');
+        // 1
+        // 5
+        // 4
+        // 2
+        // 3
+
+        // console.log('Start');
+        // setTimeout(() => {
+        //     console.log('Timeout 5');
+        // }, 100);
+        // new Promise((resolve) => {
+        //     console.log('Promise 4');
+        //     resolve();
+        // }).then(() => {
+        //     console.log('Promise 5');
+        // });
+        // console.log('End');
+        // start
+        // Promise 4
+        // end
+        // Promise 5
+        // Timeout 5
+
+        // console.log('Start');
+        // setTimeout(() => {
+        //     console.log('Timeout 2');
+        // }, 100);
+        // for (let i = 0; i < 5; i++) {
+        //     console.log(i);
+        // }
+        // start
+        // 0
+        // 1
+        // 2
+        // 3
+        // 4
+        // Timeout 2
+
+
+        console.log('Start');
+        setTimeout(() => {
+            console.log('Timeout 7');
+        }, 0);
+        async function asyncFunc() {
+            console.log('Async 1');
+            await new Promise((resolve) => {
+                console.log('Promise 8');
+                resolve();
+            });
+            console.log('Async 2');
+        }
+        asyncFunc();
+        console.log('End');
+    </script>
+</body>
+
+</html>