vue for each循环出来数组的某一项 再重新合并成一个新数组

 search() {
      request
        .get("/manager")
        .then(res => {
          if (res.code == 20000) {
            this.tableData = res.data.list;
            var categorystr = ''
            var classifystr = ''
            this.tableData.forEach(function(c) {
              categorystr += c.category + ","
              classifystr += c.classify + ","
            });
            categorystr = categorystr.substring(0,categorystr.length-1)
            classifystr = classifystr.substring(0,classifystr.length-1)
            this.categoryList = categorystr.split(",")
            this.classifystr = classifystr.split(",")
            // console.log(str)
            // console.log(this.categoryList)
          }
        })
        .catch(err => {
          console.log(err);
        });
 

 

 

posted @ 2019-12-10 10:57  小小小小小前端  阅读(8660)  评论(0编辑  收藏  举报