[]List选中项下滚会变

List中选中checkbox,下拉条滑动,返回,checkbox的label会改变。。。。(服务器2变为服务器35)如果再选择别的选项,该checkbox的label又会变回服务器2;引入的js页面如下:(语言javascript,引擎1.7.8beta)
 

var ServerListView = (function(_super){
function ServerListView(){
ServerListView.super(this);
this.selectedIndex = -1;
var data = ;
//设置服务器列表项信息
for(var i=0;i<100;i++){
data = {select:{label:"服务器"+(i+1),selected:false},
flag:{text:(i==0)?"(推荐)":""}};
}
this.sList.dataSource = data;//批量赋值
this.sList.selectEnable = true;//列表项是否可选
// this.sList.selectHandler = Laya.Handler.create(this,this.onSelect,null,false);
this.sList.mouseHandler = new Laya.Handler(this,this.onMouse);//鼠标事件响应
}
Laya.class(ServerListView,"ServerListView",_super);
var _proto_ = ServerListView.prototype;
//选择列表项时的相应时间,参数index是选中项的下标
// _proto_.onSelect = function(index){
// console.log("index",index);
// }
_proto_.onMouse = function(e,index){
if(e.type == Laya.Event.CLICK){
//console.log(e.type,index);
if(this.selectedIndex !== index){
if(this.selectedIndex!==-1){
//之前选中的列表项的选中状态设置为false
this.sList.setItem(this.selectedIndex,{
select : {label : "服务器"+(this.selectedIndex+1),selected : false},
flag : { text : (this.selectedIndex===0)?"(推荐)":""}
});
}
this.selectedIndex = index ;
}
//把当前选中的列表项的选中状态设置为true
this.sList.setItem(index,{
select : { lable : "服务器"+(index+1),selected: true},
flag : { text : (index===0)?"(推荐)":""}
});
}
}
return ServerListView
})(ServerListUI);
 
QQ截图20170805142440.png QQ截图20170805142430.png QQ截图20170805142607.png
已邀请:

cuixueying

赞同来自:

应该是你自己渲染逻辑的问题,可以把你能运行的例子上传下,我们看下!

要回复问题请先

商务合作
商务合作