2014-10-31 51 views
1

我試圖用聚合物動畫的網頁,但它是 在控制檯上返回一個錯誤:聚合物:綁定連接到核心動畫的頁面

Uncaught TypeError: Cannot set property 'selected' of null 

這裏是代碼

<core-animated-pages id="pp" selected="0"> 
    <section id="signin"> 
      aa 
      <a href="/#" onclick="hi()">cc</a> 
    </section> 
    <section id="signup"> 
     bb 
    </section> 
<core-animated-pages> 
<script> 
    function hi(){ 
     var pp = document.getElementById('pp'); 
     pp.selected='1'; 
    } 
</script> 
</template> 
<script> 


    Polymer({}); 
</script> 

回答

0

這對我的作品。注意:selected應該設置爲一個整數索引,而不是一個字符串。

<script src="http://www.polymer-project.org/platform.js"></script> 
 

 
<link rel="import" href="http://www.polymer-project.org/components/core-animated-pages/core-animated-pages.html"> 
 

 
<core-animated-pages id="pp" selected="0"> 
 
    <section id="signin"> 
 
      aa 
 
      <a href="/#" onclick="hi()">cc</a> 
 
    </section> 
 
    <section id="signup"> 
 
     bb 
 
    </section> 
 
<core-animated-pages> 
 

 
    <script> 
 
    function hi(){ 
 
     var pp = document.getElementById('pp'); 
 
     pp.selected= 1; 
 
     return false; 
 
    } 
 
</script>