element icon indicating copy to clipboard operation
element copied to clipboard

使用tabs组件出现了 Uncaught TypeError: Cannot read property 'index' of undefined(…) 的bug

Open zhangkuiworld opened this issue 9 years ago • 2 comments

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>

zhangkuiworld avatar Dec 15 '16 06:12 zhangkuiworld

请提供demo

baiyaaaaa avatar Dec 19 '16 03:12 baiyaaaaa

遇到过这种问题,当时是因为某个属性读不出来,既然用element的框架,为什么还有手写呢,组件的table下面有里面的prop属性可以直接绑定某一行某个属性,或者不用prop。在行内写row.XX直接可以访问你属性

yuanyuanshen avatar Dec 22 '16 03:12 yuanyuanshen