Invalid prop: custom validator check failed for prop “options“.

vue+antd  级联选择

报错原因:

this.options = res.data

尤为层级children里有的是null,才导致报这个警告。

修改为:

this.options =  this.formatData(res.data)
   //格式化数据,递归将空的children置为undefined
    formatData(data) {
      const that = this
      data.forEach((element) => {
        if (element.children && element.children.length > 0) {
          that.formatData(element.children)
        } else {
          element.children = undefined
        }
      })
      return data
    },

你可能感兴趣的:(antD,vue.js,ant)