美文网首页
TypeScript定义接口

TypeScript定义接口

作者: 践道修行者 | 来源:发表于2020-08-05 16:13 被阅读0次

定义接口

interface IPerson {
    firstname: string,
    lastname: string,
    sayHi:()=>string
}

//实现接口
let customer: IPerson = {
    firstname: 'zhang',
    lastname: 'shang',
    sayHi: ():string => { return "hi" }
}
console.log(customer.firstname)
console.log(customer.sayHi())

相关文章

网友评论

      本文标题:TypeScript定义接口

      本文链接:https://www.haomeiwen.com/subject/nyxorktx.html