覆盖ES6中的静态getter

时间:2019-04-22 00:05:53

标签: javascript inheritance ecmascript-6 static

假设我有这样的ES6 mixin:

// InputMixin.js
export const InputMixin = (base) => {
  return class Base extends base {

    static get _attribs() {
      return ['autofocus', 'autocomplete', 'form', 'formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget', 'name', 'type', 'value']
    }

    static get properties(){
      var props = {}

      for (let attribute of this._attribs) {
        props[attribute] = {
          attribute,
          reflect: false,
          converter: { fromAttribute: (value, type) => { } }
        }
      }
      return props
    }
  }
}

还有一个使用mixin并想要扩展静态getter properties()的类……它实际上是如何访问它的?

// InputButton.js
import { LitElement, html } from 'lit-element'
import { InputMixin } from './InputMixin.js'

class InputButton extends InputMixin(LitElement) {

  static get properties() {
    // How do I access the mixin's properties here?
    // I want to return those, and some extra ones
    debugger
  }

}
customElements.define('nn-input-button', InputButton)

0 个答案:

没有答案