var Viewmode = { PANORAMA: 'panorama', DOLLHOUSE: 'dollhouse', FLOORPLAN: 'floorplan', TRANSITIONING: 'transitioning' } Viewmode.toInt = function(mode) { switch (mode) { case this.PANORAMA: return 1 case this.DOLLHOUSE: return 2 case this.FLOORPLAN: return 3 case this.TRANSITIONING: return -1 } throw new Error('未知模式: ' + c) } Viewmode.fromInt = function(mode) { switch (mode) { case '1': case 1: return this.PANORAMA case '2': case 2: return this.DOLLHOUSE case '3': case 3: return this.FLOORPLAN } throw new Error('未知模式: ' + c) } export default Viewmode