用抽象 class (打字稿)中的原型覆盖函数
Overwriting a function with prototype from an abstract class (typescript)
我的打字稿class(基础)
namespace customNamepsace
{
export abstract class SomeAbstractClass
{
public SomeFunction()
{
//Some (standard)action
}
}
}
在一些其他的里面class(覆盖一个函数):
class AnotherClass extends customNamepsace.SomeAbstractClass
{
customNamepsace.SomeAbstractClass.prototype.SomeFunction=function()
{
//overwrite that (standard)action
}
}
我得到:
Unexpected token. A constructor, method, accessor, or property was
expected.
在这里做什么?
如果您想覆盖 SomeFunction
的行为,试试这个:
class AnotherClass extends customNamepsace.SomeAbstractClass
{
public SomeFunction()
{
//Code to override the behavior of the base class
}
}
我的打字稿class(基础)
namespace customNamepsace
{
export abstract class SomeAbstractClass
{
public SomeFunction()
{
//Some (standard)action
}
}
}
在一些其他的里面class(覆盖一个函数):
class AnotherClass extends customNamepsace.SomeAbstractClass
{
customNamepsace.SomeAbstractClass.prototype.SomeFunction=function()
{
//overwrite that (standard)action
}
}
我得到:
Unexpected token. A constructor, method, accessor, or property was expected.
在这里做什么?
如果您想覆盖 SomeFunction
的行为,试试这个:
class AnotherClass extends customNamepsace.SomeAbstractClass
{
public SomeFunction()
{
//Code to override the behavior of the base class
}
}