2016-01-08 68 views
3

我的代碼:聚合物觀察者不會觸發

<google-youtube currenttime="{{videoTime}}" video-id="{{videoUrl}}"></google-youtube> 

<script> 
    Polymer({ 
     is: 'youtube-video', 

     properies: { 
      videoUrl: String, 
      videoTime: { 
       type: Number, 
       observer: 'timeChanged' 
      } 
     }, 

     timeChanged: function(){ 
      console.log('observer'); 
     } 
    }); 
</script> 

聚合物督元素:https://elements.polymer-project.org/elements/google-youtube

enter image description here

timeChanged功能不會被調用。爲什麼?


在此先感謝;)

+0

代碼對我來說看起來不錯,你是否試圖將當前時間綁定到span標籤以查看它實際上在工作?我懷疑這個元素可能有錯誤 – Cristian

+0

你的意思是'google-youtube'元素? –

+0

是的,我可以看到'google-youtube'元素沒有任何適當的測試(對於1.0),並且'currenttime'屬性被'self.currenttime = value'改變,而不是'this.set('currenttime ',價值)'。因此我懷疑那裏有一個bug。 – Cristian

回答

3

你在你的properties聲明(缺少),從而觀察者從未註冊有一個錯字。 google-youtube元素正常工作,並按預期更新currenttime