我正在尝试使用管道中的typescript将数字值转换为角度为2的字符串 . 它抱怨
类型字符串不能分配给类型编号
. 我的管道如下 .
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'pxsuffix'
}) export class pxsuffix implements PipeTransform {
transform(input: number): number {
if ((input > 0)) {
input = input.toString(),
}
return (
input = input + 'px',
);
}
}
1 回答
您的函数要求返回一个Number并返回一个String . 尝试: