美文网首页
ts (抄写的)

ts (抄写的)

作者: 糖醋里脊120625 | 来源:发表于2022-08-29 13:09 被阅读0次

    继承

      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};
    

    相关文章

      网友评论

          本文标题:ts (抄写的)

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