@@ -7,6 +7,7 @@
</head>
<body>
<!-- <script src="./1.ts" type="module"></script> -->
- <script src="./类型/1.js"></script>
+ <!-- <script src="./类型/1.js"></script> -->
+ <script src="./面向对象/dist/1.类.js"></script>
</body>
</html>
@@ -0,0 +1,18 @@
+"use strict";
+/**
+ * 通过class定义一个类
+ */
+class Person {
+ say() {
+ console.log("你好");
+ }
+}
+Person.name1 = '图图';
+Person.age = 3;
+// 实例化
+let p1 = new Person();
+// p1.age = 12;
+console.log(p1, 'p1');
+Person.age = 12;
+console.log(Person.age);
+p1.say();
@@ -0,0 +1,26 @@
+ readonly name1:string = '图图';
+ static age:number = 3;
+ console.log("你好")
+ /**
+ * static 静态属性
+ * 属性添加static后 变成了 类
+ * 只能通过类 去更改
+ * 规避name字段
+ * readonly 只读
+
+// p1.name1 = 'aaa';
+console.log(p1,'p1')
+console.log(Person.age)
+// let xxx = function() {}
+// function fn1() {}
+// (function(){})()
+// function fn2(() => {})
+// function Fn1() {
+// }
+// new Fn1()
+class Person1{
+ name2:string;
+ age2:number;
+ constructor(x:string,y:number) {
+ this.name2 = x;
+ this.age2 = y;
+let p2 = new Person1('图图',3)
@@ -0,0 +1,14 @@
+{
+ "include": [
+ "./src/**/*"
+ ],
+ "compilerOptions": {
+ "target": "es2015",
+ "module": "es2015",
+ "lib": ["dom","ES2015"],
+ "outDir": "./dist",
+ "strict": true,
+ "noImplicitThis": false,
+ "noImplicitAny": false