(二十六)interface 类继承

老怪兽2022年11月29日
  • TypeScript
  • Ts
小于 1 分钟

一、interface 类继承

说明

上一章节我们使用 interface 类的继承,这一章节我们来学习一下 interface 类的继承

interface Product {
    title: string
    price: number
}

// 继承上面的属性, 然后在添加自己独有的属性
interface Tshirt extends product {
    size: 'S' | 'L' | 'M'
}

let product: Product = {
    title: '牛仔裤',
    price: 100,
    size: 'M'
}

总结-写在最后

总结

这种继承方式,也可以采用面向对象里面的继承来最大话的复用代码

Loading...