zheng 3 săptămâni în urmă
părinte
comite
f5d4f1bafb

+ 20 - 0
15.ts/3.编译选项/dist/a1.js

@@ -0,0 +1,20 @@
+"use strict";
+var obj = {
+    name: '张三'
+};
+function fn3() {
+    console.log(this.name, 'this');
+    return this.name;
+}
+console.log(fn3.call(this.obj));
+let rr = 12;
+rr = false;
+let we;
+we = 'str';
+we = 12345;
+function test(x, y) {
+    console.log('test');
+    return x + y;
+}
+test(32, 54);
+let x = document.getElementById("app");

+ 1 - 1
15.ts/3.编译选项/index.html

@@ -7,6 +7,6 @@
 </head>
 <body>
     <script
-    src="./dist/app.js"></script>
+    src="./dist/a1.js"></script>
 </body>
 </html>

+ 42 - 11
15.ts/3.编译选项/src/a1.ts

@@ -1,14 +1,45 @@
-let a3 = 12;
-console.log(a3);
-// document.getElementById
-// document
-alert('hello ts');
-// let a4:any = 12;
-// let a4:any = 34;
+// let a3 = 12;
+// console.log(a3);
+// // document.getElementById
+// // document
+// alert('hello ts');
+// // let a4:any = 12;
+// // let a4:any = 34;
 
+// // let a4: number = 34;
+// // a4 = 'str';
+// // document.getElementById("app").innerHTML = "hello ts";
 // let a4: number = 34;
-// a4 = 'str';
-// document.getElementById("app").innerHTML = "hello ts";
-let a4: number = 34;
-// a4 = 'ew';
+// // a4 = 'ew';
 
+var obj = {
+    name: '张三'
+}
+function fn3() {
+    console.log(this.name,'this')
+    return this.name;
+}
+console.log(fn3.call(this.obj));
+
+
+let rr:any = 12;
+rr = false;    
+
+let we;
+we = 'str';
+we = 12345;
+
+function test(x,y) {
+    console.log('test');
+    return x + y;
+}
+test(32,54);
+
+
+let x = document.getElementById("app");
+// x?.onclick = function() {
+//     console.log("你好")
+// }
+// x?.addEventListener('click',function() {
+//     console.log("你好")
+// })

+ 6 - 1
15.ts/3.编译选项/tsconfig.json

@@ -41,7 +41,12 @@
         // 不允许错误编译
         // "noEmitOnError": true,
         // 规定文件是否编译
-        "noEmit": true
+        // "noEmit": true,
+        "strict": true
+        // "noImplicitThis": false,
+        // "noImplicitAny": false,
+        // "strictNullChecks": true,
+        // "alwaysStrict": true
         
     }
 }