关注分享主机优惠活动
国内外VPS云服务器

引入打字稿学习路径(如何学习打字稿)

摘要:为研究道路安装环境启动开发工具文件的开发工具文件中自动编译数据类型。继承类的定义。静态属性和继承类别的多态性抽象类之间的接口。安装环境。安装开始,并创建了一个新版本。路径在路径下方。 打字稿学习道路安装系统的路径。打字稿学习道路安装系统。启动打字稿。启动打字稿。启动打字稿。启动打字稿。启动打字稿。启动打字稿。启动打字稿。启动打字稿。启动打字稿。启动打字稿。 TypeScript开发工具VSCODE自动编译。 TTS文件。打字稿数据类型。打字稿功能。 タイプスクリプト定义。打字条定义。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。打字稿继承。输入字样类型类静态属性和类型属性类别类型类型抽象类接口类型类型类型

typescript学习路径类型环境NPM安装- g typescript

查看版本tsc - v typescript

1。hello.ts hello.ts

tsc hello.ts

3。此时,Hello.js文件将在路径中生成

var hello =“ Hello world!”; console.log(Hello);

4。打开节点hello.js或介绍xxx.ht打开并查看ML浏览器

打字稿开发工具vscode会自动编译.TS文件

1。在创建tsconfig.json文件cmd之后,运行命令tsc - - - init以生成配置文件

p> p> p> p> p> p> p> p> p>键入任何null和未定义的void Typenever类型*///布尔值类型booleanvar flag:boolean = trueflag = false //数字类型numberVar编号:number = 123console.log(num); //字符串类型stringlet str:string =“ fqniu” console.log(str); 3,4] console.log(arr1);令ARR2:string [] = [] = [“ 1”,“ 2”,“ 3”,“ 4”] console.log(arr2); //第二定义让ARR3:array = [1,2,3,4] true] //祖先类型的元组(如何定义一个数组)让ARR7:[String,number,boolean]= [“ fqniu”,25,true] //枚举类型枚举flag {success = 1,error = - 1}让fs:flag = flag.successlet fe:flag = flag = flag.errconsole.log(fs,fe); // 1 - 1enum颜色{红色,蓝色,黄色} //如果默认情况下未分配值,则打印索引值。 // 2枚举color1 {红色,蓝色= 5,yellow} //如果默认未分配值,则打印索引值。 // 0console.log(cb); // 5console.log(cy); // 6先前的值,蓝色+1 //获取任何类型的值任何numany:any = 25numany =“ fqniu” numany = trueconsole.log(numany); //任何用途:获取DOM Element节点与DOM样式等一起使用。//var obox:any = document.getElementById(“ box”)// obox.style.color =“ red” // null and undefinedlet redef:undefinedconsole.log.log(undef); var null:nullnul = nullnul.log.log.log(nulnul);类型可能为null。它可能不确定:数字| null | undefinedConsole.log(Ele); // ypedscript中的void type void表示没有类型。它通常用于定义方法。此方法使用值函数fun():void {console.log(“ fun”);} fun()//如果有返回值,则fun1():number {console.log(“ fun”);返回123} fun1()//从不键入:其他类型的亚型(包括空和未定义)表示不可见的值。 } // js函数表达式的匿名函数的定义var fun2 = function(){} // ts function fun3():string {返回“ fqniu”} console.log(fun3()); // fqniu // ts函数的匿名函数的定义var fun4 = function():number {return 25} console.log(fun4())); // 25 // 1。函数传输参数函数fun5(名称:字符串,年龄:number):字符串{return`$ {name} - - $ {age} console.log(fun5(“ fqniu”),25)); // fqniu - - 25 var fun6 =函数(名称:字符串,年龄:number):string {return`$ {name} - - - $ {age}`} console.log(fun6(fun6)(fun6(“ nfq”,22)); // nfq - - 22 //无返回值fun7()的方法函数:void {console.log(“ fun7”);} fun7()请注意,必须将参数设置为最后一个参数。 添加?函数fun8(名称:字符串,年龄?:number):字符串{if(age){返回`$ {name} - - $ {age} e els {return {return $ {name} - - - forcectorial`} console.log(fun8(“ fqniu”,25); // fqniu - - 25 // 3。(“ fqniu”,25); // fqniu - - 25 // 4。剩余的参数函数函数sum1(a:b:number,c:number,d:number):number {返回a + b + c + d} console.log(sum1(1,2,2,3,4)); // 10function sum2(...结果:number []):number {var sum = 0 for(var i = 0; i {console.log(“ fqniu ws'');},2000);定义timpleScript class //在TS类中定义类的类{name:string; // actuntion构造函数(名称:字符串){//省略构造函数之前省略的公共关键字。 } fun():void {console.log(“ fun”,this.name); } getName():字符串{return this.name} setName(name:string):void {th​​is.name = name}} var p = new Person(“ fqniu”)console.log(p.name); // fqniuconsole.log(p.getName()); // fqniup.setName(“ niuniu”)console.log(p.getName()); // niuniu从javascript函数person(){this.name =“ fqniu”/*属性*/this.age = 25 this.fun = function(){console.log(this.name + this.age); }} var p = new person()console.log(p.name); P.Fun()//原型链属性在多个实例上共享,但构造函数并未共享。 Person.Prototype.sex =“ Male” person.prototype.work = function(){console.log(this.name +“ code-touching”); } p.work()//静态方法person.getInfo = function(){console.log(“ i static方法”); } person.getInfo()//继承班的继承// 1。 Object spoofing inheritance function web1() {person.call(this)// object spoofing implements inheritance} var web1() web1.fun() web1.fun() web1.fun()// Implement object index Typeerror: web.work is not a function, but there is no way to inherit properties and methods in the prototype chain. // // fqniu web2.fun()// fqniu25 web2.work()//fqniu代码 - 触摸//原型链实现的优势继承:构造函数的属性和方法,或原型链的方法//原型链实现继承问题? サブクラスをインスタンス化する场合、パラメーターを亲クラス函数person 1 name){this.name = name /*属性* /this.age = age this.fun = function = function(){console.log this.name + this.age)function web3} function web3(name,年龄){} console.log(web3.name); // UNDFENIND,在实例化子类时,无法将参数传递给父类//组合继承模式函数person2(name,age){this.name = name/*name/*property*/ this.age = age = age = age = age = age = age = function(console.log(console.log)(console.log(this.name + this.age); }} person2.Prototype.sex =“ male” person2.prototype.work = function(){console.log(this.name +“ code-touch”); }函数web4(name,age){person2.call(this,name,age)//对象模仿继承,实例化子类并将参数传递给父级} web4.prototype = new person2()//原型链实现继承//或/ web4.protype = person2.prototypevar web4 = new web4(“ nfq”,25)console.log(web4.name); // NFQ web4.fun()// NFQ25 web4.work()// NFQ Code toxpionScript sashitance // ts sashitance,扩展,超级类人{name:string; //属性省略public关键字构造函数(名称:字符串){// constructor方法class this this.name = name; name; } fun():void {console.log(“ fun”,this.name); } getName():string {return this.name} setName(name:string):void {th​​is.name = name}} class class web扩展了persem {structoror(name){super(super(name)//初始化父级}的构造者}:void {void {console.log.log.log`.log'name} $ { “ Fun -子类”,this.name); //}} var w = new web(“ fqniu”)w.fun()// fun fqniuw.work()// fqniu提供三个修改器/*publi for Code //类Typercript修改C:公共 - 可在当前类,子类和受课程保护的类上访问。由当前类,子类和类访问的受保护类型 - 在类外部无法访问。私有 - 仅在当前类中访问,在未修改的子类,类和属性之外无法访问。

未经允许不得转载:主机频道 » 引入打字稿学习路径(如何学习打字稿)

相关推荐

评论 抢沙发

评论前必须登录!