码迷,mamicode.com
首页 > 其他好文 > 详细

for in 循环

时间:2018-05-26 13:00:00      阅读:341      评论:0      收藏:0      [点我收藏+]

标签:index   lis   sea   let   arc   .post   config   .data   result   

  this.$ajax.post(this.$httpConfig.config.rolelist, params)
          .then(res => {
            if (res.data.code === 2000) {
              this.searchRoleList = res.data.data.list;
              let result = [],//定义一个数组
                tmpData = this.searchRoleList;//要循环的对象
              for (let index in tmpData) {
                result.push({‘id‘: tmpData[index].roleId, ‘value‘: tmpData[index].roleName});//将你要的id和value以对象的形式追加到数组里
              }

              cb(result);
            }
          })
          .catch(res => {
            this.searchRoleList = [];
            cb(this.searchRoleList);
          });

for in 循环

标签:index   lis   sea   let   arc   .post   config   .data   result   

原文地址:https://www.cnblogs.com/lml-lml/p/9092511.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!