简单的picker使用方法
var newPicker = new mui.PopPicker({
layer: num //num为选择器的层级数
});
//获取数据 这里的data是一个多维(层)json
newData = getPickData(Data);
//设置数据到picker上
newPicker.setData(newData);
var inpPick = document.getElementById('这里填写触发picker的html的id');
//单击inpick
inpPick.addEventListener('tap', function(event) {
newPicker.show(function(items) {
//这里具体赋值到哪里看你个人需要
console.log(JSON.stringify(items))
})
})
function getPickData(data) {
var retData = new Array();
var retDatas = new Array();
for(var i = 0; i < data.length; i++) {
if(data[i].ChildrenClass.length != 0) {
retDatas = getPickData(data[i].ChildrenClass);
//这里的data[i].ChildrenClass 看你数据的具体形式填写替换,下面的InterID,InterName 也是
}
retData[i] = {
value: data[i].InterID,
text: data[i].InterName,
children: retDatas
}
}
return retData;
}