TypeScript定义接口

2020-08-05  本文已影响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())
上一篇下一篇

猜你喜欢

热点阅读