2016-08-30 2 views
1

사용자 정의 요소로 가져온 요소의 모든 특성을 콘솔에 인쇄하는 방법은 무엇입니까?Polymer 1.x : Polymer 요소의 모든 속성을 인쇄하는 방법은 무엇입니까?

예를 들어, 사용자 정의 요소 my-el이 있고 해당 요소에 firebase-document 요소를 가져 왔습니다. 특정 시점에서 firebase-document의 모든 속성 값을 관찰하여 firebase-document 요소에 대한 모델의 현재 상태를 알고 싶습니다.

내-el.html
<firebase-document id="document" 
        app-name="my-app" 
        data="{{data}}"> 
</firebase-document> 
... 
foo: function() { 
    ... 
    var doc = this.$.document; 
    // Neither of the following "works" (see below for definition) 
    console.log('doc', doc); 
    console.log('doc.properties', doc.properties); 
} 

의 작품, 나는 그것이 콘솔에 객체를 인쇄 원하는 동작을 생성하지 않는 것을 의미한다. 객체는 doc 객체 인 all the properties입니다. 댓글에서

+1

'console.dir (doc)'을 시도 했습니까? – Supersharp

+0

@Supersharp : 그건 작동합니다. 감사. – Mowzer

답변

1

당신은 console.dir()를 사용할 수 있지만, 당신은 또한 표준 console.log() 호출에서 %o 대체 문자열을 사용할 수 있습니다

console.log('doc=%o', doc); 

list of substition strings은 MDN의 웹 사이트에서 이용할 수 있습니다.

1

요약 :

사용

console.dir(doc); 
관련 문제