0
を印刷し、underscorejsプロパティによってグループオブジェクトが、私はこの配列を持っている彼らに
[
{section: 'Sales', ItemName: ['Type', 'Try'] Texts: ["Having selected the account heading select the calculation ...", "This is not happenning tho."]},
{section: 'Taxes', ItemName: ['Type'] Texts: ['Having selected the account heading select the calculation.']}
]
だから私はそれを印刷すると、各セクションのテキストだけが印刷されます。私が試してみました
var log = function(contents) {
if (_.isArray(contents)) {
_.each(contents, function(e, i, l) {
log(e);
$('#result');
$('#result').append('</br></br>');
});
} else {
console.log(contents);
$('#result').append(contents);
}
};
var ty = [
{
"Language": "en-GB",
"Section": "Sales",
"ItemName": "Type",
"Texts": "Having selected the account heading select the calculation ..."
},
{
"Language": "en-GB",
"Section": "Sales",
"ItemName": "Try",
"Texts": "This is not happenning tho ..."
},
{
"Language": "en-GB",
"Section": "Taxes",
"ItemName": "Save",
"Texts": "The Master Tax Table has been pre populated with the current UK, ..."
}];
var out = [];
_.groupBy(ty.Section, function(item){
section: item.Section
_.each(ty, function(item) {
var hold = {};
hold.options = {};
hold.options.section[item.ItemName] = {
text: item.Texts,
};
out.push(hold)
});
});
log(out);
:
この
は、私がこれまで持っているコードです//More code above
_.each(ty, function(item) {
iName: item.itemName;
var hold = {};
hold.options = {};
hold.options.section.iName = {
text: item.Texts,
};
out.push(hold)
が、まだそれは何も印刷されません。私の開発ツールでは何も表示されません。
ヒント?
それは下線で実行する必要があります/ – noel293
@GeorgeXReplay。私はjavascriptコードのアンダースコア版を追加しました。 –