Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

vue中 报错 Cannot read property 'push' of undefined" 是什么原因

如题,不知道怎么 我调用组件的时候就报出这个错误了

<slide-out
      dock="right"
      :visible="slideOutAttr.visiblity"
      :size="slideOutAttr.size"
      :z-index="10"
      @close="onClose"
    >
      <div slot="header" slot-scope="title">{{ title }}</div>
      <AssignAE :code-list="codeList" :visible="slideOutAttr.visiblity" :on-close="onClose" :save-callback="saveCallBack" :assign-id="slideOutAttr.selectedAssignId" />
    </slide-out>
// 信息-添加行
      addNewDetail () {
        const that = this
        that.generateId();
        that.generateSerialNumber();
        that.assignInfoList.orderAssignInfo.push({
          detailId: that.tempId,
          serialNumber: that.serialNo
        })
        console.log(that.tempId)
        console.log(that.serialNo)
        // console.log(that.assignInfoList)
      },
      // 信息-删除行
      deleteDetail (row) {
        const that = this
        that.assignInfoList.splice(row.index, 1)
        for (let i = 0; i < that.assignInfoList.length; i++) {
          that.assignInfoList[i].serialNumber = i + 1
          that.serialNo = i + 1
        }
      },

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

建议查一下空值,that.assignInfoList.orderAssignInfo 空值的情况下是 undefined,就会报这个错误。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...