문제

I want my element to have specific JavaScript API. For example like HTMLInputElement that have checked property, I want my element to have a property that you can only set binary values to it and I have callbacks to changes.

도움이 되었습니까?

해결책

This described in detail in the documentation.

Properties and methods are defined on the element's prototype using the Polymer() constructor.

Polymer('my-element', {
  name: 'Mohsen',
  isChecked: false,
  isCheckedChanged: function() {
    console.log('I am checked?', this.isChecked);
  },
  ...
});

To define a property as boolean, make sure to hint its type.

Use <prop>Changed watchers to be notified when the <prop> changes.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top