简单粗暴直接上代码:

// 这样写时会报错 Type of the default value for 'record' prop must be a function 
  props: {
    record: {
      type: Array,
      default: []
    }
  }
 
// 正确应该这样写
// 因为vue规定,对象或数组默认值必须从一个工厂函数获取
  props: {
    record: {
      type: Array,
      default: function () {
          return []
      }
    }
}

 

      data() {
          return {
              newRecord: this.record  // record直接使用如果报错,可以先赋值给另外的变量,再进行其他操作 
          }
      }
 

相关文章:

  • 2022-01-06
  • 2022-03-05
  • 2021-07-19
  • 2021-05-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-20
  • 2022-12-23
  • 2022-12-23
  • 2021-11-12
  • 2022-12-23
  • 2021-10-09
  • 2021-09-23
相关资源
相似解决方案