2014-05-12 24 views
0

我一直在高興地開發聚合物應用程序。一切進展順利,但一些相當基本的東西在Chrome Dev和Chrome Canary中不起作用,這是預期的嗎?跨Chrome元素不能工作的元素聚合物數據綁定/金絲雀

這裏有一個減少我所看到的[codepen to try it out yourself]的:

<script src="http://www.polymer-project.org/platform.js"></script></script> 
<link rel="import" href="http://www.polymer-project.org/components/polymer/polymer.html"> 

<my-app></my-app> 

<polymer-element name='my-app'> 
    <template> 
    <my-processor input='{{input}}' output='{{output}}'> 
    <input value='{{input}}'> <br> 
    Input: {{input}} <br> 
    Processed: {{output}} 
    </template> 
    <script> 
    Polymer('my-app', { 'input': 'hello world', }); 
    </script> 
</polymer-element> 

<polymer-element name='my-processor' attributes='input output'> 
    <script> 
    Polymer('my-processor', { 
     inputChanged: function() { 
     this.output = this.input + ' (processed)'; 
     } 
    }); 
    </script> 
</polymer-element> 

在Chrome瀏覽器開發和金絲雀從不顯示處理後的輸出。我使用調試器來查看inputChanged是否在my-processor元素上觸發,但是my-app從未獲取更新後的輸出值。

在Chrome 34中,Safari和Firefox一切都按預期工作,處理後的輸出按預期顯示。

回答

2

根據控制檯中的警告,my-processor定義高於my-app(使用它)很重要。需要首先註冊my-processor才能正確拾取綁定。

http://jsbin.com/xovegoga/3/edit

+0

哇哦,它一直盯着我的臉。不知道爲什麼我的大腦將這標記爲不重要的警告。謝謝! –