温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

vue如何实现table表格里面数组多层嵌套取值

发布时间:2022-08-02 09:26:01 来源:亿速云 阅读:884 作者:iii 栏目:开发技术

这篇文章主要介绍“vue如何实现table表格里面数组多层嵌套取值”,在日常操作中,相信很多人在vue如何实现table表格里面数组多层嵌套取值问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”vue如何实现table表格里面数组多层嵌套取值”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

    vue table表格里面数组多层嵌套取值

    我现在是在表格里拿到级联选择器的多选的id,然后要根据这个id来匹配一个嵌套了三层的数组的第三层id,来拿名字渲染

    表格部分

    <tr >                 <td >提醒给</td>                 <td >                   <!-- {{editForm.uids.toString().split(',')}} -->                   <span v-for="item in editForm.uids.toString().split(',')" :key="item.id">                     <!-- <p>{{dataHandle(editForm.uids)}}</p> -->                     <p>{{dataHandle(item)}}</p>                   </span>                 </td>               </tr> ``

    methods里面定义方法

     // 提醒给点击事件 dataHandle(item) {    let ary = []  let name = ''   let result = getUserName(this.options4)   result.forEach(v2 => {     if (item == v2.id) {       name = v2.corp_name     }   })   return name      function getUserName(item) {     item.forEach(v1 => {       if (v1.children) return getUserName(v1.children)       else {         ary.push(v1)       }     })     return ary   } },

    vue 多层数组嵌套循环,动态取值匹配

    tableData:[], //存储数组 arrTarName:[] //结果数组   this.tableData.push({   siteName:i.siteName,   tabdata:result.data });    //循环+判断取值 for (let k = 0; k < result.data.length; k++) {     if (this.arrTarName.length == 0) {         this.arrTarName.push({             indexName: result.data[k].indexName,             polTracesouCount: result.data[k].polTracesouCount         })     } else {         let isExist = false;         for (let l = 0; l < this.arrTarName.length; l++) {             if (this.arrTarName[l].indexName == result.data[k].indexName) {                 isExist = true;                 this.arrTarName[l].polTracesouCount = this.arrTarName[l].polTracesouCount + result.data[k].polTracesouCount;                 break;             }         }         if (!isExist) {             this.arrTarName.push({                 indexName: result.data[k].indexName,                 polTracesouCount: result.data[k].polTracesouCount             })         }     } } console.log(this.arrTarName)

    到此,关于“vue如何实现table表格里面数组多层嵌套取值”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!

    向AI问一下细节

    免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

    AI