zoukankan      html  css  js  c++  java
  • typeScript类型别名

    类型别名
    类型别名:是可以给一个类型起一个新的名字
    采用关键字 type 例如 type Name=string|number
    type strType=string|number|boolean; // strType 可以表示 3 中类型
    var str:strType="10"; //表示其中的一种 为字符串
    str=true;
    
    ### 对于接口也可以使用 类型别名
    // 定义一个接口 为字符串类型的
    interface num1 {
    name: string;
    }
    
    interface num2 {
    age: number;
    }
    
    // 类型别名 numType 可以去描述字符串或者是数字
    type numType = num1 | num2;
    
    // 描述的是 字符串
    var obj1: numType = { name: "张三" };
    var obj2: numType = { age: 12 };
    var obj3: numType = { name: "张三", age: 12 };
    
  • 相关阅读:
    python 爬虫 urllib模块 url编码处理
    python 爬虫 urllib模块 目录
    python 爬虫 urllib模块介绍
    python 爬虫 目录
    爬虫 介绍
    POJ 2533
    POJ 2531
    POJ 2524
    POJ 2505
    POJ 2521
  • 原文地址:https://www.cnblogs.com/IwishIcould/p/12443129.html
Copyright © 2011-2022 走看看