callMethod 调用方法
2025/4/16小于 1 分钟
callMethod 调用方法
案例
案例一
模型
class Test extends ModelBase {
public concatString() {
this.res = this.a + this.b
}
@Column()
public a!: string
@Column()
public b!: string
@Column()
public res?: string
}
实例初始化
const test = new Test({
a: "xx",
b: "hh",
})
调用函数
执行 ModelBase 内部的方法
ModelBase.callMethod(test, { method: "concatString" })
打印日志
console.log(test)
// { a: "xx", b: "hh", res: "xxhh" }