【VUE】- for循环遍历对象 - 对象转数组

    var messagetype={
            OA消息: "oa"
            markdown消息: "markdown"
            卡片消息: "action_card"
            图片消息: "image"
            文件消息: "file"
            文本消息: "text"
            链接消息: "link"
     }
     for (let key in messagetype) {
     console.log(key);//获取对象属性
     console.log(messagetype[key]);//获取对象属性对应的值

        //将遍历出的对象和属性转换成数组,push到数组中
        this.dingdingType.push({
          name: key,
          type:messagetype[key],
        });
      }

猜你喜欢

转载自blog.csdn.net/dopdkfsds/article/details/113445311