这个数据无法使用map遍历吗?

image.png
定义的dacaData类

/**
 * @classdesc 字典数据
 * @property {String} label 标签
 * @property {*} value 标签
 * @property {Object} raw 原始数据
 */
export default class DictData {
  constructor(label, value, raw) {
    this.label = label
    this.value = value
    this.raw = raw
  }
}

字典

/**
 * 加载字典
 * @param {Dict} dict 字典
 * @param {DictMeta} dictMeta 字典元数据
 * @returns {Promise}
 */
function loadDict(dict, dictMeta) {
  return dictMeta.request(dictMeta).then((response) => {
    const type = dictMeta.type;
    let dicts = dictMeta.responseConverter(response, dictMeta);
    if (!(dicts instanceof Array)) {
      console.error("the return of responseConverter must be Array.<DictData>");
      dicts = [];
    } else if (
      dicts.filter((d) => d instanceof DictData).length !== dicts.length
    ) {
      console.error("the type of elements in dicts must be DictData");
      dicts = [];
    }
    dict.type[type].splice(0, Number.MAX_SAFE_INTEGER, ...dicts);
    dicts.forEach((d) => {
      Vue.set(dict.label[type], d.value, d.label);
    });
    return dicts;
  });
}
阅读 1k
2 个回答

一看就是若依那一套

如果是数组对象没有map方法,可以参考一下通过apply来实现

Array.prototype.map.apply(list,(item)=>{
    ...
})
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题