微信小程序 功能函数 把数字1,2,3,4换成春,夏,秋,冬

let season =‘1,2,3’;
// console.log(season.length)
if (season){
if (season.length==1){
seasonChe1=season.substr(0);
seasonChe1 = parseInt(seasonChe1)
switch (seasonChe1) {
case 1:
(function(){
seasonChe2='春'
})()
break;
case 2:
(function () {
seasonChe2 = '夏'
})()
break;
case 3:
(function () {
seasonChe2 = '秋'
})()
break;
default:
(function () {
seasonChe2 = '冬'
})()
}
}else{
seasonChe1 = season.split(",");
for (let i = 0; i<seasonChe1.length;i++){
let che='';
che=seasonChe1[i];
che = parseInt(che)
switch (che) {
case 1:
(function () {
seasonChe1[i]= '春'
})()
break;
case 2:
(function () {
seasonChe1[i] = '夏'
})()
break;
case 3:
(function () {
seasonChe1[i] = '秋'
})()
break;
default:
(function () {
seasonChe1[i]= '冬'
})()
}
}
seasonChe2 = seasonChe1.join(",")
}
}
item.season = seasonChe2
that.setData({
detailDatas: item
})
posted @ 2017-12-07 09:45  ThisCall  阅读(448)  评论(0编辑  收藏  举报