能否请您提供一个示例以在打字稿中实现Polymer mixin行为? 我正在尝试在打字稿中编写Polymer混合,如下所示:
export var testMixin = Polymer.dedupingMixin((superClass : (new ()=> Polymer.Element))=>
{
return class extends superClass
{
ready()
{
super.ready();
console.log("Test Mixin");
}
}
});
,但是生成的打字稿定义已连接。
生成的打字稿定义:
export var testMixin: (superClass: new () => Polymer.Element) => {
new (): {
ready(): void;
accessKey: string;
readonly children: HTMLCollection;
contentEditable: string;
readonly dataset: DOMStringMap;
dir: string;
draggable: boolean;
hidden: boolean;
hideFocus: boolean;
innerText: string;
readonly isContentEditable: boolean;
lang: string;
-------------------------------------已更新。
我终于在ts中有了mixin了:
export interface ocITestMixin
{
property1: Object;
}
export interface ocITestMixinConstructor
{
new(...args: any[]): ocITestMixin;
}
export var ocTestMixin =
Polymer.dedupingMixin((superClass: (new () => Polymer.Element) & Polymer.decorators.ElementConstructor) =>
{
return class ocTestBehavior extends superClass
{
property1: Object;
} as ((new () => Polymer.Element) & Polymer.decorators.ElementConstructor & ocITestMixinConstructor);
});
--------要使用此ocTestMixin的文件
import { ocITestMixin, ocITestMixinConstructor } from 'ui';
export class ocZoomTextBox extends UI.ocTestMixin(Polymer.Element)
{
}