我在game.coffe文件中写下以下代码
App.game = App.cable.subscriptions.create "GameChannel",
connected: ->
...
disconnected: ->
...
received: (data) ->
switch data.action
when "game_start"
$('#status').html("Player found")
App.gamePlay = new Game('#game-container', data.msg)
when "take_turn"
App.gamePlay.move data.move
App.gamePlay.getTurn()
when "new_game"
App.gamePlay.newGame()
when "opponent_withdraw"
$('#status').html("Opponent withdraw, You win!")
$('#new-match').removeClass('hidden');
take_turn: (move) ->
@perform 'take_turn', data: move
new_game: () ->
@perform 'new_game'
当我在浏览器中运行此代码时,它会向我显示这样的错误
game.self-9aed049….js?body=1:42 Uncaught ReferenceError: Game is not defined
在浏览器的控制台中。