1. 程式人生 > >微信小程序 功能函數 把數字1,2,3,4換成春,夏,秋,冬

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

cas i++ substr length tail efault 微信 ++ 數字

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 })

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