2016-07-27 2 views
1

jsbin에서 요소의 콘텐츠를 업데이트하고 수업을 추가하려면 어떻게해야합니까?폴리머 구성 요소의 내용과 클래스를 업데이트하는 방법은 무엇입니까?

this.$.content.innerHTML = "Changed?"this.classList.add('new')은 작동하지 않습니다.

다음과 같이 jsbin의 코드는 다음과 같습니다

:host.new { 
    background: blue; 
} 
... 
make: function() { 
    this.classList.add("new"); 
    Polymer.dom(this).innerHTML = "changed?"; 
} 
: 이것은 속임수를 썼는지
<!DOCTYPE html> 
<html> 
<head> 
    <base href="http://polygit.org/components/"> 
    <script src="webcomponentsjs/webcomponents.min.js"></script> 
    <link href="polymer/polymer.html" rel="import"> 
</head> 
<body> 
    <my-element>Some text</my-element> 
    <dom-module id="my-element"> 
    <template> 
     <style> 
     :host { 
      background: lightgrey; 
     } 
     .new { 
      background: blue; 
     } 
     </style> 
     <content> 
     </content> 
     <button on-tap="make">Make blue</button> 
    </template> 
    <script> 
     HTMLImports.whenReady(function() { 
     Polymer({ 
      is: 'my-element', 
      make: function() { 
      this.$.content.innerHTML = "Changed?"; 
      this.classList.add('new'); 
      } 
     }) 
     }) 
    </script> 
    </dom-module> 
</body> 
</html> 

답변

관련 문제