1、创建自定义管道: ng g pipe 目标文件夹/管道名字 (使用命令行创建,会自动在根模块文件中挂载) 2、配置管道文件: fangda.pipe.ts import { Pipe, PipeTransform } from '@angular/core'; @Pipe({ name: 'fangda' }) export