Several ways of receiving props in vue-Type of the default value for'minetlist' prop must be a function

Pass value in parent component:

 <mineConponent :minetlist="mineList" />

The sub-component receives:

  1. The first way of writing: directly use props to receive as a one-dimensional array
	props: ['minetlist']
  1. The second way of writing: use the object form to receive, and give the default value, but there is a problem with the array here, a big hole, please see the third
 props: {
    
    
    minetlist: {
    
    // 数组这里接收有问题,请看第三种
      type: Array, // 类型
      default: [] // 默认值
    },
     minetom: {
    
    
      type: Number,
      default: 0
    }
  },
  1. The third way of writing: receiving an array, it needs to be received in the form of a function
 props: {
    
    
    minetlist: {
    
    
      type: Array,
      default: function () {
    
    
        return []
      }
    }
  },

Guess you like

Origin blog.csdn.net/m0_46442996/article/details/110236330