在angular中挂载函数到原型链
2019-11-08 本文已影响0人
伶念
在environment.ts文件中
declare global {
interface String {
test(c: number): string;
}
interface Array<T> {
test(c: number): string;
}
interface Array<T> {
every2(callbackfn: any, thisArg: any);
}
}
String.prototype.test = function (c: number) {
return "abc";
}
Array.prototype.test = function (c: number) {
return "123";
}