今天把2D的框架移到3D上来的时候,发现了许多依赖引用的问题。
请教一下:
情况1:
class Base {
public static P1 = 10;
public static P2 = P1 + 1;
}
报错:TypeError: Cannot read property 'P1 ’ of undefined
情况2:
export const enum Enum1 {
EnumV = 1,
}
报错:转换失败:$SyntaxError:
情况3:
// Base.ts
export class Base {
public static funcCaller = null;
}
// Base2.ts
export class Base2 {
// do something
}
Base.funcCaller = function() {
// do something
}
报错:TypeError: Cannot set property ‘funcCaller’ of undefined
情况4:
export class Base extends Component{
@property(LabelComponent)
@BindUIField(GameCenter, “coins”, Base.ShowCoins)
public coinsLabel: LabelComponent = null;
public static ShowCoins() {
// do something
}
}
报错:TypeError: Cannot read property ‘ShowCoins’ of undefined
情况5:
// BindUIComponent.ts
import BindUIManager from “…/BindEvent/BindUIManager”;
export default class BindUIComponent extends Component {
private InitBindObject(): void {
let bindObject = BindUIManager.GetBindUIObject(this.constructor);
// do something
}
}
// BindUIHandlerManager.ts
import BindUIComponent from “./BindUIComponent”;
export default class BindUIHandlerManager {
public static GetUIHandler<T>(propertyValue: Component): Action<BindUIComponent, any, T, any> {
// 没有使用BindUIComponent,只是用来做返回值推导使用。
}
}
构建警告: Circular dependency:
情况N:
不知道有没有解答,有后续了再来。