[英]I have this code below and I want the console to display the text
I have this code below and I want to use the underscore in order to display the text below... 我在下面有此代码,我想使用下划线以在下面显示文本...
var log = function(contents) {
if(_.isArray(contents)) {
_.each(contents, function(e, i, l) {
log(e);
$('#result');
$('#result').append('</br></br>');
});
} else {
$('#result').append(contents);
}
};
var out = [];
_.each(ty, function(v,k){
var hold = {};
hold.o = {
l: {
s:{
t: 'Trying this for first time...'
}
}
};
out.push(hold);
});
Console.log(out.l.s);
I want to display the text 'Trying this for the first time...' 我想显示文本“第一次尝试...”
You can't do out.ls
on an array
. 您不能在
array
上执行out.ls
out
is an array, so in order to print all the text you have to iterate over the array out
是一个数组,因此为了打印所有文本,您必须在数组上进行迭代
Replace: 更换:
Console.log(out.l.s);
With: 带有:
_.each(out, function(item) {
console.log(item.o.l.s.t)
});
You could just log the array like this: 您可以像这样记录阵列:
console.log(out)
But that will print the entire array structure with all the objects in it, and not just the text 但这将打印出其中包含所有对象的整个数组结构,而不仅仅是文本
语法错误,请尝试console.log(out);
Thank a lot for your answer, but actually, what i want is something similar to what is below: 非常感谢您的回答,但实际上,我想要的是与下面类似的东西:
hold.options (tooltips object) = {
(property based on the section generated automatically): {
(properly based on the itemName generated automatically): {
t: item.Texts,
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.