小编PDH*_*ide的帖子

如何在打字稿中使用“this”上下文定义函数

type Animal = {
    name: string
}

function getBear(this: Animal) : Animal {
    this.name = "hi"
    return this
}

console.log(getBear().name)
Run Code Online (Sandbox Code Playgroud)

谁能帮我解决这个问题,我无法调用 getBear 函数

javascript typescript typescript-typings

4
推荐指数
1
解决办法
4131
查看次数