我想知道我的React中可以有pipes或filters吗?
例如这样的东西:
import { Pipe, PipeTransform } from '@angular/core';
/*
* Raise the value exponentially
* Takes an exponent argument that defaults to 1.
* Usage:
* value | exponentialStrength:exponent
* Example:
* {{ 2 | exponentialStrength:10 }}
* formats to: 1024
*/
@Pipe({name: 'exponentialStrength'})
export class ExponentialStrengthPipe implements PipeTransform {
transform(value: number, exponent: string): number {
let exp = parseFloat(exponent);
return Math.pow(value, isNaN(exp) ? 1 : exp);
}
}
OR
{{消息|大写}}
filters: {
capitalize: function (value) {
if (!value) return ''
value = value.toString()
return value.charAt(0).toUpperCase() + value.slice(1)
}
}
React也有可能吗?
答案 0 :(得分:0)
您需要使用以下命令安装其他软件包:
npm install --save react react-pipeline
您可以在这里找到完整的信息: https://www.npmjs.com/package/react-pipeline