Vue warn]: Error in v-on handler (Promise/async): "TypeError: Cannot read properties of undefined (reading 'length')"
TypeError: Cannot read properties of undefined (reading 'length')
//改变状态
async deleteUser1() {
for (let i = 0; i < this.casesId[i].length; i++) {
console.log("11111", this.casesId[i].length);
let parmars = {
articleId: this.casesId[i],
casesStat: 10,
};
let res = await article.updateart(parmars);
console.log("22222", res);
}
this.getCaseList();
},
<el-table-column
prop="casesStat"
v-model="deleteUser1"
label="状态"
width="80"
>
<template slot-scope="{ row }">
{{ row.casesStat | statDate }}
</template>
</el-table-column>
<el-button size="mini" type="primary" @click="deleteUser1()"
>屏蔽</el-button
有没有老前辈,搭救一下
vue.esm.js?a026:628 [Vue warn]: Error in v-on handler (Promise/async): "TypeError: Cannot read properties of undefined (reading 'length')"
found in
---> <ElButton> at packages/button/src/button.vue
<Anonymous>
<ElMain> at packages/main/src/main.vue
<Index> at src/views/Index.vue
<App> at src/App.vue
<Root>
vue.esm.js?a026:1906 TypeError: Cannot read properties of undefined (reading 'length')
at _callee3$ (Caselist.vue?8692:238:1)
at tryCatch (runtime.js?96cf:63:1)
at Generator.invoke [as _invoke] (runtime.js?96cf:294:1)
at Generator.eval [as next] (runtime.js?96cf:119:1)
at asyncGeneratorStep (asyncToGenerator.js?1da1:3:1)
at _next (asyncToGenerator.js?1da1:25:1)
at eval (asyncToGenerator.js?1da1:32:1)
at new Promise (<anonymous>)
at eval (asyncToGenerator.js?1da1:21:1)
at VueComponent.deleteUser1 (Caselist.vue?8692:238:1)
this.casesId[i]打印下看这里的格式
程序中可以看出只是在 this.casesId[i].length
这里使用了length
,你应该是写错了this.casesId[i].length
--->this.casesId.length
很明显就是你调用length的变量是个undifined,输出一下这个变量你就知道是哪里的问题了