首页 > 解决方案 > 这个 TypeScript 代码中的“:”是什么意思?

问题描述

我不明白:这段代码中 second 的含义是什么:

  getDish(id: number): Observable<Dish> {
    return  this.restangular.one('dishes',id).get();
  }

我知道第一种:方式 id 具有类型号,它是getDish()函数的输入参数。但是第二个:做什么呢?它是函数的输出类型,getDish()并且意味着输出是Dish具有该Observable类型的类的对象吗?

标签: typescriptobservablecolon

解决方案


请查看以下说明

id: number <-- type of the id variable is number
getDish(id: number): Observable<Dish> <-- the return value of the function i GetDish is of type Observable<Dish>

推荐阅读