1。下面這種interface里帶new的格式是什么意思?interface?xxx{
????new?(str:string):number;
}沒有new的話我知道是限制一個(gè)方法的參數(shù)和返回值。2。在一個(gè)class里可以使用setter和getter,如何用interface限定某一個(gè)class里必須有某個(gè)getter?class?xxx{
?????private?name:string;
?????get?Name():string{
?????????return?this.name;
?????}
}
interface?Named{
get?Name():string;//然而這兩種格式都不行?
Name():string;
}
TypeScript中的Interface的兩個(gè)問題。
我吃西瓜很快
2017-03-27 10:26:27