element
element copied to clipboard
使用tabs组件出现了 Uncaught TypeError: Cannot read property 'index' of undefined(…) 的bug
ElementUI version
1.0.5
OS/Browers version
Chrome 54
Vue version
2.4.0
What is Expected?
怎么导致的?
What is actually happening?
<template>
<div class="right-content">
<el-tabs @tab-click="changeClass" :active-name="currClass" ref="tabs">
<el-tab-pane v-for="clazz in classData" :label="clazz.name" :name="clazz.class_code" >
<table class="table">
<thead>
<tr>
<th class="username">姓名</th>
<th>学号</th>
</tr>
</thead>
<tbody>
<tr v-for="student in clazz.students">
<td>
student.name
</td>
<td>
student.student_number
</td>
</tr>
</tbody>
</table>
</el-tab-pane>
</el-tabs>
</div>
</template>
<script>
export default{
data(){
return {
currClass:'',
classData:[]
}
},
methods:{
listenPagination(pageNo){
this.curPageNo = pageNo
},
changeClass(data){
this.currClass = data.name
console.log(data.name)
}
},
mounted(){
this.$http.get("/student/list-by-teacher").then((response) => {
let allData = JSON.parse(response.data)
if(allData.code == 0){
this.classData = allData.data
this.currClass = allData.data[0].class_code
} else if(allData.code == 555){
} else {
this.$alert(allData.message)
}
}, (response) => {
this.$alert(response)
})
}
}
</script>
请提供demo
遇到过这种问题,当时是因为某个属性读不出来,既然用element的框架,为什么还有手写