2016-08-19 3 views
1

Polymer 요소의 속성을 정의 할 때 Polymer 요소의 매우 이상한 동작을 발견했습니다 ... 특히 Array 및 Objects.폴리머 속성 주문 ... 중요합니까?

일부 데이터를 제공하기 위해이 데이터 배열을 표시하는 dom-repeat 템플릿이 있습니다. 예를 들어

: 이것은 이러한 속성의 순서를 전환하지만 만약 잘못 렌더링

//.... Template definition 
<script> 
    Polymer({ 
     is: 'sample-element', 
     properties:{ 
      user: { 
       type:Object, 
       notify: true, 
      }, 
      data:{ 
       type: Array, 
       value: function(){ 
        return [ 
        {'name':"Facebook", 'website': "http://www.facebook.com"}, 
        {'name':"Twitter", 'website':"http://www.twitter.com"}, 
        {'name':"Google",'website':"http://www.google.com"}]; 
       }, 
      } 
     } 
    }); 
</script> 

데이터는 템플릿 렌더링 3 객체 어레이로서 정의된다. 예를 들어

:

//.... Template definition 
<script> 
    Polymer({ 
     is: 'sample-element', 
     properties:{ 
      data:{ 
       type: Array, 
       value: function(){ 
        return [ 
        {'name':"Facebook", 'website': "http://www.facebook.com"}, 
        {'name':"Twitter", 'website':"http://www.twitter.com"}, 
        {'name':"Google",'website':"http://www.google.com"}]; 
       }, 
      }, 
      user: { 
       type: Object, 
       notify: true, 
      }, 
     } 
    }); 
</script> 

이 개체가 마지막으로 정의 작동 왜 어떤 단서? 콘솔에서 샘플 요소에 오류가 표시되지 않습니다.

답변

0

기본값을 사용하는 경우 실제로 순서가 중요합니다.

user은 아직 설정되지 않은 data의 값에 액세스하려합니다.

관련 문제