Who lost Brexit?

Labour's loss in last week's British election is being widely blamed on Brexit. But what exactly could it have done differently?