[LayaAir 2.0]Laya List给子元素添加事件后,滚动事件被劫持了
let storeTxList = new Laya.List();
storeTxList.itemRender = StoreItem;
storeTxList.name = 'storeTxList';
storeTxList.width = 610;
storeTxList.pos(0, 0);
storeTxList.repeatX = repeatX;
storeTxList.repeatY = repeatY; //y轴个数
// 使用但隐藏滚动条
storeTxList.vScrollBarSkin = "store/c.png";
let scrollBar = storeTxList.getChildByName('scrollBar');
scrollBar.showButtons = false;
let slider = scrollBar.slider;
slider.bar.stateNum = 1;
let txArray = ;
for (let i = 0; i <20; ++i) {
let list = new Laya.Sprite();
list.width = 600 ;
list.height = 155;
list.loadImage('xxx.png');
//此处无论是这样给
list.on(Laya.Event.CLICK, this, () => {
console.log(413132131)
})
//还是在handler中去渲染,都会滚动不了
txArray.push(list);}
storeTxList.array = txArray;
Laya.stage.addChild(storeTxList);
悬赏找大神看问题
export default class StoreItem extends Laya.Box {
constructor() {
super();
this.size(195, 210);
}
}
storeTxList.itemRender = StoreItem;
storeTxList.name = 'storeTxList';
storeTxList.width = 610;
storeTxList.pos(0, 0);
storeTxList.repeatX = repeatX;
storeTxList.repeatY = repeatY; //y轴个数
// 使用但隐藏滚动条
storeTxList.vScrollBarSkin = "store/c.png";
let scrollBar = storeTxList.getChildByName('scrollBar');
scrollBar.showButtons = false;
let slider = scrollBar.slider;
slider.bar.stateNum = 1;
let txArray = ;
for (let i = 0; i <20; ++i) {
let list = new Laya.Sprite();
list.width = 600 ;
list.height = 155;
list.loadImage('xxx.png');
//此处无论是这样给
list.on(Laya.Event.CLICK, this, () => {
console.log(413132131)
})
//还是在handler中去渲染,都会滚动不了
txArray.push(list);}
storeTxList.array = txArray;
Laya.stage.addChild(storeTxList);
悬赏找大神看问题
export default class StoreItem extends Laya.Box {
constructor() {
super();
this.size(195, 210);
}
}
没有找到相关结果
已邀请:
3 个回复
Another
赞同来自:
aicode
赞同来自:
大光电KID
赞同来自: