-
Creator 版本:2.2.1-rc.4
-
目标平台: mac 编辑器
问题描述:图片中有说明,还不确定是BUG,第一次写插件不怎么熟悉div、ccs这些,也许是我操作有问题,折腾了一晚上希望有大神指点一二。

Creator 版本:2.2.1-rc.4
目标平台: mac 编辑器
问题描述:图片中有说明,还不确定是BUG,第一次写插件不怎么熟悉div、ccs这些,也许是我操作有问题,折腾了一晚上希望有大神指点一二。

补上测试代码
let ListItem = Editor.UI.registerElement('list-item', {
template: `
<div class="layout horizontal" style="padding: 2px; background-color:yellow;">
<ui-input id="input" class="flex-1" disabled></ui-input>
<ui-button id="del" class="tiny red">删除</ui-button>
</div>
`,
factoryImpl ( text ) {
this.$ = {
input: this.shadowRoot.querySelector('#input'),
del: this.shadowRoot.querySelector('#del')
};
this.$.input.value = text;
}
});
let el = new ListItem("内容");
listEle.appendChild(el);
已搞定,因为cocos自己封装的ui样式不生效,如layout horizontal这类的,所以要自己处理
let ListItem = Editor.UI.registerElement('list-item', {
template: `
<div class="item"">
<ui-input id="path" class="path" disabled></ui-input>
<ui-button id="del" class="tiny red">删除</ui-button>
</div>
`,
style: `
.item {
display: flex;
background-color: yellow;
padding: 2px;
}
.path {
flex: 1;
}
`,
factoryImpl ( text ) {
this.$ = {
path: this.shadowRoot.querySelector('#path'),
del: this.shadowRoot.querySelector('#del')
};
this.$.path.value = text;
}
});
怎么结贴??