2016-09-06 38 views
0
vCard { 
    version: '4.0', 
    data: { 
    version: [String: '4.0'], 
    n: [String: 'Gump;Forrest;;;'], 
    fn: [String: 'Forrest Gump'], 
    org: [String: 'Bubba Gump Shrimp Co.'], 
    title: [String: 'Shrimp Man'], 
    photo: { [String: 'http://www.example.com/dir_photos/my_photo.gif'] mediatype: 'image/gif' }, 
    tel: [ 
     { [String: 'tel:+11115551212'] type: [ 'work', 'voice' ], value: 'uri' }, 
     { [String: 'tel:+14045551212'] type: [ 'home', 'voice' ], value: 'uri' } 
    ], 
    adr: [ 
     { [String: ';;100 Waters Edge;Baytown;LA;30314;United States of America'] 
     type: 'work', 
     label: '"100 Waters Edge\\nBaytown, LA 30314\\nUnited States of America"' }, 
     { [String: ';;42 Plantation St.;Baytown;LA;30314;United States of America'] 
     type: 'home', 
     label: '"42 Plantation St.\\nBaytown, LA 30314\\nUnited States ofAmerica"' } 
    ], 
    email: [String: '[email protected]'], 
    rev: [String: '20080424T195243Z'] 
    } 
} 

我找不到任何有關[String: 'Gump;Forrest;;;']意味着什麼的信息,我該如何訪問該值本身?每當我在節點console.log它,我得到js對象中括號內的這些類型值是什麼意思?

[String: 'Forrest Gump (Full Name)'] 

回答

4

閱讀the fine manual後,我發現,獲得「FN」屬性的值的方法是:

let fullName = card.get('fn').valueOf(); 
+0

也做到了,但多了一個問題,爲什麼每當你只有簡單的console.log時[String:value]呢? – Cayle

+0

@Cayle它重載了'card'對象的'toString()'屬性,並顯示了它的一個「漂亮」版本(這不是一個有效的JS對象,但我認爲它不是這樣的)。 – robertklep

+0

奇怪,這樣做有什麼好處? – Cayle