【发布时间】:2017-06-14 16:56:41
【问题描述】:
这是我的问题:
我有一个班级机器人。每次创建此类的对象时,我都想填充它。然后将其显示在玉文件上。到目前为止我有:
//bot.js
var listeBots = [];
exports.listeBots = listeBots;
// Constructeur
function Bot (nom, probavoyager, probatweet, probaretweet, nbhashtag, probalien, probalike, probamention, probaselfmention, visibilite,probaphoto) {
this.nom = nom;
this.probavoyager = probavoyager;
this.probatweet = probatweet;
this.probaretweet =probaretweet;
this.nbhashtag = nbhashtag;
this.probalien = probalien;
this.probalike = probalike;
this.probamention = probamention;
this.probaselfmention = probaselfmention;
this.visibilite = visibilite;
this.probaphoto = probaphoto;
}
exports.BotSuiveur = function(name){
Bot.call(this, name, 0.2, 0.2, 0.8, 1, 0.4, 0.8, 0.8, 0.2, 0.05, 0.1 );
listeBots.push(this);
//console.log(this);
};
exports.BotLeader = function(name){
Bot.call(this, name, 0.2, 0.8, 0.4, 2, 0.6, 0.4, 0.4, 0.8, 0.8, 0.2 );
listeBots.push(this);
//console.log(this);
};
function BotVoyageur() {
Bot.call(this, 0.8, 0.6, 0.4, 5, 0.4, 0.4, 0.4, 0.8, 0.15, 0.8 );
//console.log(this);
}
// jade file
each kw in listeBots
li= kw
我的翡翠文件只显示了 Object[Object] 等等 如何获取翡翠中可见的对象值?
提前致谢! 罗曼
【问题讨论】:
-
为什么不迭代它并显示它的值?
-
你是什么意思?我确实在我的玉代码中对其进行了迭代
-
listeBots 中的每个 kw li= kw
-
可以附上你的玉码吗?感谢您的回复。
-
我做到了。谢谢你的帮助
标签: arrays node.js object express pug