ts (抄写的)

2022-08-29  本文已影响0人  糖醋里脊120625

继承

  class Father {
    public name: string;
    public age: number;
    public money: number;
    constructor(name: string, age: number, money: number) {
      this.name = name;
      this.age = age;
      this.money = money;
    }
    getName(): string {
      return this.name;
    }
    setName(name: string): void {
      this.name = name;
    }
  }
  class child extends Father {
    constructor(name: string, age: number, money: number) {
      super(name, age, money);
    }
    desc() {
      console.log(`${this.name}${this.age}${this.money}`);
      // 属性“money”为私有属性,只能在类“Father”中访问
    }
  }
  let children = new child('金色小芝麻', 18, 1000);
  console.log(children.name);
  console.log(children.age); // 
  console.log(children.money); // 

ts 数组对象vue

import { itemBook, itemBanner, paramsType } from './type';
const bannerData = ref<itemBanner[]>([]);
const listData = ref<itemBook[]>([]);


type.ts
interface itemBook {
    id: number;
    recommendStatus?: boolean;
    pic?: string;
    name?: string;
    minPrice?: string | number;
    originalPrice: number;
    titleColor?: string;
    typeTitle?: string;
    url?: string;
}

interface itemBanner{
    id:number;
    linkUrl:string;
    picUrl:string;
    title:string;
}

interface paramsType {
    page: number;
    pageSize: number;
  }

  export { itemBook , itemBanner,paramsType};
上一篇下一篇

猜你喜欢

热点阅读