我有一个聚合物元素,里面有一些模板和其他元素。我可以决定将哪种项目显示(项目,复选框,输入或按钮)bin绑定到模板。我使用这个,所以我可以生成自定义事件,在所有使用的元素和其他一些东西上具有相同的语法。我也有这个元素,而不是制作数以百万计的扩展和单独的元素。
我的问题是:这是否有效?在整个应用程序中使用这样的模板?
....
<template id="aInput">
<paper-input required="{{isRequired}}"
value="{{label}}"
flex>
<content></content>
</paper-input>
</template>
<template id="aCheckbox">
<paper-checkbox on-change="{{checkEvent}}"
checked="{{isChecked}}">
<content></content>
</paper-checkbox>{{label}}
</template>
<template id="{{aIcon}}">
<core-icon icon="{{icon}}"
style="width: 32px; height: 32px;"></core-icon>
</template>
<template bind ref="{{aTemplate}}">
<!-- Item -->
</template>
.....
tapEvent : function ()
{
// Event shall be not fired if the item ignores Fire
if (!this.ignoreFire && (this.aTemplate === 'aItem' || this.aTemplate === 'aButton'))
{
this.fire(this.eventhandler,
{
'label' : this.label,
'itemid' : this.itemid,
'link' : this.link,
'ability' : this.ability,
'isButton' : this.isButton,
'eventhandler' : this.eventhandler,
'icon' : this.icon,
'reference' : this
});
}
},
答案 0 :(得分:0)
它过时了,可能已经过时但我们放弃了这个模板。原因是(或者是)无穷无尽的进口,因此不断增长的shadowDOM将减缓整个网站的速度。特别是对于低速移动设备,使用该组件时,进行http调用所需的时间和渲染时间都会增加。在硫化和抛弃这个元元素之后,渲染时间减少,数据传输减少,从而减少了加载时间并进一步调用。