2020/4/23 - 每日一记

1.vue报错Error in render: "TypeError: Cannot read property 'length' of undefined"

<tr v-for="(returnExchangeProductAddRQS, index) in returnExchangeProductList">
  <td>
    <el-form-item
      :prop="'returnExchangeProductAddRQS.' + index + '.questionContent'">
      <el-select
        v-model="returnExchangeProductAddRQS.questionContent"
        placeholder="请选择问题描述">
        <el-option v-for="item,index in returnExchangeProductAddRQS.questionsInfoList"
                   :key="item.id"
                   :label="item.questionContent"
                   :value="item.questionContent">
        </el-option>
      </el-select>
    </el-form-item>
  </td>
</tr>

   循环的data中,又嵌套了一层数组,给外层数组添加子内容时,未给添加的子内容中的数组初始化。

 解决方案:

// 添加行数据
addDomain() {
  this.returnExchangeProductList.push({ 
    questionsInfoList: [],
  });
},

2.vue中数据嵌套层数深,数据已改变视图层未刷新

 解决方案

// 强制刷新
forceRefresh() {
  this.$forceUpdate();
},

3.elemetUI校验问题:输入框中有数据,但是校验不通过

 解决方案:给定初始值

this.$set(this.form.returnExchangeProductAddRQS[index],"questionType", '');
this.$set(this.form.returnExchangeProductAddRQS[index], "questionContent", '');

 

posted @ 2020-04-23 14:30  迷糊的小元宝  阅读(146)  评论(0编辑  收藏  举报