获取省(第一级)
获取市(第二级)
获取区县(第三级)
需要注意的是,级联字段不能直接作为函数的参数。
var date = new Date(生日字段); var month= date.getMonth() + 1; var day=date.getDate(); function getAstro(month,day){ var s="摩羯水瓶双鱼白羊金牛双子巨蟹狮子处女天秤天蝎射手摩羯"; var arr=[20,19,21,21,21,22,23,23,23,23,22,22]; return s.substr(month*2-(day<arr[month-1]?2:0),2); } return getAstro(month,day)+'座'
var txt = 文本字段; var l = txt.length; return l
var len = 数字长度; let chars = '0123456789'; let maxPos = chars.length; let str = ''; for (let i = 0; i < len; i++) { str += chars.charAt(Math.floor(Math.random() * maxPos)); } return str
var len =字符串长度; let _charStr = 'abacdefghjklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789', min = 0, max = _charStr.length-1, _str = ''; //定义随机字符串 变量 //判断是否指定长度,否则默认长度为15 len = len || 15; //循环生成字符串 for(var i = 0, index; i < len; i++){ index = (function(randomIndexFunc, i){ return randomIndexFunc(min, max, i, randomIndexFunc); })(function(min, max, i, _self){ let indexTemp = Math.floor(Math.random()*(max-min+1)+min), numStart = _charStr.length - 10; if(i==0&&indexTemp >=numStart){ indexTemp = _self(min, max, i, _self); } return indexTemp ; }, i); _str += _charStr[index]; } return _str
https://help.mingdao.com/function.html