-
多行字符串模板查看全部
-
箭头表达式,单行返回的话,不需要加“{}”和return 多行的话是要加“{}”和return查看全部
-
声明类型及自定义类型查看全部
-
声明类型查看全部
-
TypeScript还要安装线上线下环境啊查看全部
-
1.类型定义文件是为了能在TS上使用JS代码库、框架而引入的以.d.ts结尾的文件。 2.类型定义文件是别人配好的:https://github.com/DefinitelyTyped/DefinitelyTyped 比如使用jq :https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/jquery/index.d.ts 3.可以使用专门用来安装类型定义文件的工具:https://github.com/typings/typings查看全部
-
//1.接口的使用必须符合定义的规范(不能缺少或多出某些属性) interface IPerson{ name: string; age: number; } class Person{ constructor(public config: IPerson) { } } var p1 = new Person({ name: "alan", age: 100 }); //2.实现接口的类必须实现接口里的方法 interface Animal{ eat(); } class Sheep implements Animal{ eat() { console.log("I eat grass"); } } class Tiger implements Animal{ eat() { console.log("I eat meat"); } }查看全部
-
class Person { constructor(public name:string) { } eat() { console.log("员工开始吃饭"); } } class emp extends Person { constructor(name:string,code:string) { super(name); console.log("constructor emp"); this.code = code; } code: string; work() { super.eat(); this.doWork(); } private doWork() { console.log("员工开始工作"); } } var workes: Array<Person> = []; workes[0] = new Person("zhangsan"); workes[1] = new emp("lisi", "1001"); var emp1 = new emp("wangwuxiao", "1001"); emp1.work();查看全部
-
class Person { constructor(public name:string) { } eat() { console.log("员工开始吃饭"); } } class emp extends Person { constructor(name:string,code:string) { super(name); console.log("constructor emp"); this.code = code; } code: string; work() { super.eat(); this.doWork(); } private doWork() { console.log("员工开始工作"); } } var workes: Array<Person> = []; workes[0] = new Person("zhangsan"); workes[1] = new emp("lisi", "1001"); var emp1 = new emp("wangwuxiao", "1001"); emp1.work();查看全部
-
`hello ${myname}`查看全部
-
安装typescript查看全部
-
class Person{ constructor(public name: string) { console.log(name); } eat() { console.log("i'm eating"); } } class Employee extends Person { constructor(name: string, public code: string) { super(name); console.log(code); this.code = code; } work() { super.eat(); this.doWork(); } doWork() { console.log("i'm working") } } var e1 = new Employee("suzic", "1abc"); e1.work(); console.log(e1.code) var workers: Array<Person> = []; workers[0] = new Person("zhangsan"); workers[1] = new Employee("suzic", "abc123"); //workers[2] = 5; //报错:5不属于Person类 console.log(workers[1]);查看全部
-
class Person{ constructor(public name: string) { console.log(name); } eat() { console.log("i'm eating"); } } class Employee extends Person { constructor(name: string, public code: string) { super(name); console.log(code); this.code = code; } work() { super.eat(); this.doWork(); } doWork() { console.log("i'm working") } } var e1 = new Employee("suzic", "1abc"); e1.work(); console.log(e1.code)查看全部
-
有默认值的参数要放在最后 可选参数放在必选参数后面查看全部
-
1.类型定义文件是为了能在TS上使用JS代码库、框架而引入的以.d.ts结尾的文件。 2.类型定义文件是别人配好的:https://github.com/DefinitelyTyped/DefinitelyTyped 比如使用jq :https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/jquery/index.d.ts 3.可以使用专门用来安装类型定义文件的工具:https://github.com/typings/typings查看全部
举报
0/150
提交
取消