簡體   English   中英

我在下面有此代碼,我希望控制台顯示文本

[英]I have this code below and I want the console to display the text

我在下面有此代碼,我想使用下划線以在下面顯示文本...

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);

我想顯示文本“第一次嘗試...”

您不能在array上執行out.ls out是一個數組,因此為了打印所有文本,您必須在數組上進行迭代

更換:

Console.log(out.l.s);

帶有:

_.each(out, function(item) { 
    console.log(item.o.l.s.t)
});

您可以像這樣記錄陣列:

console.log(out)

但這將打印出其中包含所有對象的整個數組結構,而不僅僅是文本

語法錯誤,請嘗試console.log(out);

非常感謝您的回答,但實際上,我想要的是與下面類似的東西:

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM