我们声明一个 Greeter类.这个类有3个成员:一个叫做greeting的属性,一个构造函数和一个greet方法. We declare a Greeter class. This class has three members: an attribute called greeting, a constructor, and a green method 我们在引用任何一个类成员的时候都用了this.它表示我们访问的是类的成员. We use this when we refer to an…
typescript的核心原则之一就是对所具有的shape类型检查结构性子类型化 One of the core principles of typescript is to check structural subtyping of shape types 在typescript中,接口的作用就是为这些类型命名和为你的代码或第三方代码定义契约 In typescript, the function of an interface is to name these types and defin…
软件工程中,我们不仅要创建一致的定义良好的API,同时也要考虑可重用性. 组件不仅能够支持当前的数据类型,同时也能支持未来的数据类型, 这在创建大型系统时为你提供了十分灵活的功能. In software engineering, we should not only create well-defined APIs, but also consider reusability. Components can support not only current data types, but al…
基本类型 // 布尔型(Boolean) let isDone: boolean = false; // 数值型(Number) let decimal: number = 6; let hex: number = 0xf00d; let binary: number = 0b1010; let octal: number = 0o744; // 字符串(String) let color: string = "blue"; color = 'red'; // 多行字符串和模板字符串(…
函数 // 具名函数和匿名函数 // Named function function add(x, y) { return x + y; } // Anonymous function let myAdd = function(x, y) { return x + y; }; // 函数体内可以引用函数外围的变量 let z = 100; function addToZ(x, y) { return x + y + z; } // 函数类型 // 给函数加上类型 function add(x:…
React半科普文 什么是React getting started 文件分离 Server端编译 定义一个组件 使用property 组件嵌套 组件更新 Virtual DOM react native 什么是React 以下是官方定义,反正我是没看懂.google了下,大家都称之“前端UI开发框架”,勉强这么叫着吧.可以看下这篇文章对react的介绍,本文更多的是覆盖react的入门实践. A JAVASCRIPT LIBRARY FOR BUILDING USER INTERFACES 本…