首页 > 解决方案 > 找不到 'of'' Angular 的名称

问题描述

我在 Angular 7.3.2 中运行下面提到的这段代码,但出现错误

找不到'of'的名字

我尝试of在Angular中搜索关键字找不到太多信息,如果您有相关信息,请帮忙

const nums = of(1, 2, 3);

const squareValues = map((val: number) => val * val);
const squaredNums = squareValues(nums);

squaredNums.subscribe(x => console.log(x));

标签: angular

解决方案


你需要导入它

import { of } from 'rxjs';

推荐阅读