当前位置: 首页 > Web前端 > JavaScript

js基础_0

时间:2023-03-27 11:17:08 JavaScript

calcSequence(){让firstLevel=0,secondLevel=0,thirdLevel=0;constfields=this.$refs[this.pageName].fields;//所有表单字段letret={};//数组一次,不需要重新计算if(this.elFieldProps.length==fields.length){lettmpProps=fields.map((field)=>field.prop);tmpProps.sort();如果(tmpProps.join(",")==this.elFieldProps.join(","))返回;}console.log('计算序列...');this.elFieldProps=fields.map((field)=>field.prop);this.elFieldProps.sort();this.quesIds.map((quesId)=>{letquestion=this.questions[quesId];letfield=question.field;letelField=fields.find((elField)=>elField.prop==field);如果(!elField)return;constlevel=parseInt(question.level);if(level==1){secondLevel=thirdLevel=0;第一级++;ret[question.id]=this.index+'.'+第一级;}elseif(level==2){thirdLevel=0;第二级++;ret[question.id]=this.index+'.'+firstLevel+'.'+第二级;}elseif(level==3){thirdLevel++;ret[question.id]=this.index+'.'+firstLevel+'.'+secondLevel+'.'+第三级;}})this.fullSequences=ret;},***["definite","public"].includes(type)--元素是否在数组中letsets=[1,4,6,4,4,6,9];console.log(Array.from(newSet(sets)))--组去重constarr=["young","direct","indirect","sense","c3","public","definite","useMethod",“设备”,];让有={};--arr地图()使用arr.map((key)=>{letfield="has"+key.slice(0,1).toUpperCase()+key.slice(1);has[field]=this.has(key);});使用二次链接计算:{firstCats(){returnthis.options.templateCat.filter((cat)=>cat.pid==0);},secondCats(){letpid=this.dataItem.bCatId;//一级联动选择后得到bCatIdif(!pid)return[];返回this.options.templateCat.filter((cat)=>cat.pid==pid);},},