x-tag 规范在纯 JS 中具有以下签名 -
xtag.register('x-accordion', {
// extend existing elements
extends: 'div',
mixins: ['superdefaults', 'otherdefaults'],
lifecycle:{
created: function(){
// fired once at the time a component
// is initially created or parsed
},
inserted: function(){
// fired each time a component
// is inserted into the DOM
},
removed: function(){
// fired each time an element
// is removed from DOM
},
attributeChanged: function(){
// fired when attributes are set
}
},
events: {
'click:delegate(x-toggler)': function(){
// activate a clicked toggler
}
},
accessors: {
'togglers': {
get: function(){
// return all toggler children
},
set: function(value){
// set the toggler children
}
}
},
methods: {
nextToggler: function(){
// activate the next toggler
},
previousToggler: function(){
// activate the previous toggler
}
}
});
显然方法、访问器和事件可以有多个条目。
我正在尝试定义传递给 register 函数的对象文字的 Typescript 等效项。任何人有任何想法如何实现这一目标?