js "a,12,b,12" 解析成 a=12 b=12

https://www.cnblogs.com/lml-lml/p/10034096.html

 

        this.list.map((item) => {
          console.log(item, "我正在测试 时间");
          item.created = parseTime(item.created);
          // param: "a,12"   "a,12,b,12" a=12 b=12
          //第一种方法
          var arr = [];
          for (var i = 0; i < item.param.split(",").length; i++) {
            var obj = {};
            if (i % 2 == 0) {
              //判断是不是偶数
              obj.title = item.param.split(",")[i]; //是偶数的话  赋值
              obj.content = item.param.split(",")[i + 1]; //下一项给contnet赋值
              arr.push(obj);
            }
          }
          console.log(arr);
          item.param = arr;
        });
            <div v-for="item in row.param" :key="item.title">
              <span>{{item.title}}</span> =
              <span>{{item.content}}</span>
              </br>
            </div>

  

  

上一篇:NLP


下一篇:OpenCV 通道分离:split() 函数