我試圖在Cloud9上創建排行榜。但是我得到錯誤:PlayersList未定義...在編輯器中。該應用程序工作,但後來它的代碼編輯器中強調所有「不defind PlayersList」Cloud9&Meteor.js undefined global var
代碼:
PlayersList = new Mongo.Collection('players');
if(Meteor.isClient){
Template.leaderboard.helpers({
'player': function(){
return PlayersList.find({}, {sort: {score: -1, name: 1}});
},
'selectedClass': function(){
var playerId = this._id;
var selectedPlayer = Session.get('selectedPlayer');
if(selectedPlayer === playerId){
return 'selected';
}
},
'showSelectedPlayer': function(){
var selectedPlayer = Session.get('selectedPlayer');
return PlayersList.findOne(selectedPlayer);
}
});
當把它像這樣:var PlayersList =新Mongo.Collection( '玩家'); ....一切正常... – user2215585
只是編輯器的問題,還是流星抱怨呢? – Mutahhir
當我使用:var PlayersList = new Mongo.Collection('players');該應用程序將無法正常工作......但編輯器中的錯誤消失了......使用時:PlayersList = new Mongo.Collection('players');應用程序工作正常,但編輯器錯誤 - 強調var(PlayersList) – user2215585