下面的给nodeInfo.nodeType中的枚举变量赋值怎么会报错?
定义:
interface IPlayer {
playerName:String;
playerColor:Color;
}
export const enum enumNodeType {
Troop,
City
}
interface nodeInfo {
playerInfo:IPlayer;
nodeType:enumNodeType
}
在函数中使用:
let nodeInfo:nodeInfo;
nodeInfo.nodeType = enumNodeType.City
nodeInfo.playerInfo.playerName = cityScript.playerName
nodeInfo.playerInfo.playerColor = cityScript.playerColor
你这也没赋值啊
当然得赋值之后在使用
你之前等于
undefined.nodeType = enumNodeType.City
这能对吗。。。