
Vue中使用find函数
Vue中使用find函数 find函数基本使用方法:
// An highlighted block this.result = this.imgItems.find(item => item.required && !this.form[item.key])这个函数的意思是找到符合条件的对象(Object类型),并赋值给result。我自己理解的是大概下面代码要实现的逻辑。
//图片列表 export const imgItems = [ { label: "身份证(正反面放于一张图)", key: "sfzid", required: true }, { label: "学历证明", key: "xlzmid", required: true }, { label: "申请表", key: "sqbid", required: true }, { label: "推荐函", key: "tjhid", required: true }, { label: "其他材料", key: "qtid", required: false } ] const result = {} for (var i=0;i<this.imgItems.length;i++){ if (this.imgItems[i].required&&!this.form[imgItems[i].key]){ this.result = this.imgItems[i] } } *要注意的是如果不符合if中条件要求。result会是 undefined小白一枚。欢迎指正
👁️ 阅读量:0
© 版权声明:本文《Vue中使用find函数》内容均为本站精心整理或网友自愿分享,如需转载请注明原文出处:https://www.zastudy.cn/wen/1686495399a269884.html。