e 2 months ago
parent
commit
ffa671eb23

+ 1 - 1
13.Vue3/初识.md

@@ -15,4 +15,4 @@ vue2:vue create 项目名
 1.配置node环境: node -v
 vue3:
 安装命令:npm create vue@latest
-vite打包
+vite打包

+ 0 - 5
14.ts/3.编译选择/dist/b.js

@@ -1,5 +0,0 @@
-console.log("这是第二个ts文件1");
-let a = 10;
-let b = 10;
-// document.getElementById
-// document.getElementById

+ 0 - 5
14.ts/3.编译选择/dist/c.js

@@ -1,5 +0,0 @@
-console.log("这是第三个ts文件1");
-let c = 10;
-let d = 10;
-// document.getElementById
-// document.getElementById

+ 32 - 0
14.ts/3.编译选择/dist/hello.js

@@ -0,0 +1,32 @@
+console.log("这是第二个ts文件1");
+let a;
+a = '12';
+a = undefined;
+console.log(a, 'a');
+function fn1(a, b) {
+    console.log(a + b);
+}
+fn1(1, '76');
+function fn2() {
+    console.log('fn2');
+}
+fn2();
+console.log("这是第三个ts文件1");
+let c;
+c = 12;
+c = '1';
+let d = 10;
+console.log(c + d, 'x');
+let box = document.getElementById("box");
+box === null || box === void 0 ? void 0 : box.addEventListener('click', function () {
+    console.log('一个盒子');
+});
+console.log("今天天气真好");
+const age = 10;
+console.log(age, '年龄');
+define("mm", ["require", "exports"], function (require, exports) {
+    "use strict";
+    Object.defineProperty(exports, "__esModule", { value: true });
+    exports.mm = void 0;
+    exports.mm = '妹妹';
+});

+ 2 - 1
14.ts/3.编译选择/index.html

@@ -6,6 +6,7 @@
     <title>Document</title>
 </head>
 <body>
-    <script src="./a.js"></script>
+    <!-- <div id="box"></div> -->
+    <script src="./dist/hello.js"></script>
 </body>
 </html>

+ 0 - 5
14.ts/3.编译选择/src/b.js

@@ -1,5 +0,0 @@
-console.log("这是第二个ts文件1");
-let a = 10;
-let b = 10;
-// document.getElementById
-// document.getElementById

+ 16 - 2
14.ts/3.编译选择/src/b.ts

@@ -1,5 +1,19 @@
+// import {mm} from './mm'
 console.log("这是第二个ts文件1");
-let a = 10;
-let b = 10;
+// console.log(mm,'哈哈哈')
+let a;
+a = '12';
+a = undefined;
+console.log(a,'a')
+function fn1(a:any,b:any):any {
+    console.log(a+b);
+}
+fn1(1,'76')
+function fn2():void {
+    // throw new Error('报错')
+    console.log('fn2')
+}
+fn2()
+// let b = 10;
 // document.getElementById
 // document.getElementById

+ 0 - 5
14.ts/3.编译选择/src/c.js

@@ -1,5 +0,0 @@
-console.log("这是第三个ts文件1");
-let c = 10;
-let d = 10;
-// document.getElementById
-// document.getElementById

+ 10 - 2
14.ts/3.编译选择/src/c.ts

@@ -1,5 +1,13 @@
 console.log("这是第三个ts文件1");
-let c = 10;
+let c;
+c = 12;
+c = '1'
 let d = 10;
+console.log(c + d,'x')
 // document.getElementById
-// document.getElementById
+// document.getElementById
+// c='12';
+let box = document.getElementById("box");
+box?.addEventListener('click',function() {
+    console.log('一个盒子')
+})

+ 5 - 0
14.ts/3.编译选择/src/hi.js

@@ -0,0 +1,5 @@
+console.log("今天天气真好")
+const age = 10;
+// age = '20';
+
+console.log(age,'年龄');

+ 2 - 0
14.ts/3.编译选择/src/mm.ts

@@ -0,0 +1,2 @@
+// 抛出:export default/function/const
+export const mm = '妹妹';

+ 23 - 2
14.ts/3.编译选择/tsconfig.json

@@ -25,10 +25,31 @@
         // 规定ts转成什么版本的js
         "target": "ES6",
         // 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'node18', 'nodenext', 'preserve
-        "module": "ES2015",
+        "module": "amd",
         // 规定可以使用哪些库
         "lib": ["dom"],
         // 规定编译后的文件位置
-        "outDir": "./dist"
+        "outDir": "./dist",
+        // 将编译后的文件全部放在一个文件夹内
+        "outFile": "./dist/hello.js",
+        // 允许编译js文件
+        "allowJs": true,
+        // 检查js代码是否符合规范
+        "checkJs": true,
+        // 移除注释
+        "removeComments": true,
+        // 严格模式
+        // "strict": false
+        // 规定错误是否允许被编译
+        // "noEmitOnError": true,
+        // 规定文件是否允许被编译
+        // "noEmit":false,
+        // "alwaysStrict": true,
+        // 规定不允许使用any
+        "noImplicitAny": true,
+        // 规定不允许使用this
+        // "noImplicitThis": true,
+        // 检查元素是否为空
+        // "strictNullChecks": true
     }
 }

+ 1 - 1
数组值.html

@@ -34,4 +34,4 @@
     </script>
 </body>
 
-</html>
+</html>