假设我有这样的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)