elementui 动态编辑表格,为什么通过下面的v-if获取按后设置hour的值 却不改变现实内容
<el-table:data="table"borderstyle="width:100%"><el-table-columntype="selection"fixed>...
<el-table :data="table" border style="width:100%">
<el-table-column type="selection" fixed></el-table-column>
<el-table-column width="200" label="日期">
<template slot-scope="scope">
<span v-show="editable[scope.$index]">{{scope.row.date}}</span>
<span v-if="!editable[scope.$index]">
<el-input v-model="scope.row.date"></el-input>
</span>
<span style="float:right"><el-button type="text" @click="edit(scope.row,scope.$index)"><i class="el-icon-edit"></i></el-button></span>
</template>
</el-table-column>
</el-table>
<script>
export default {
data(){
return{
editable:[],
table:[
{
date: '2016-05-03',
name: '王小虎',
province: '上海',
city: '普陀区',
address: '上海市普陀区金沙江路 123弄',
zip: 200333,
editflag:false
},
...........
]
}
},
methods:{
edit(row,index){
this.editable[index]=1;
console.log(this.editable)
},
}
}
</script> 展开
<el-table-column type="selection" fixed></el-table-column>
<el-table-column width="200" label="日期">
<template slot-scope="scope">
<span v-show="editable[scope.$index]">{{scope.row.date}}</span>
<span v-if="!editable[scope.$index]">
<el-input v-model="scope.row.date"></el-input>
</span>
<span style="float:right"><el-button type="text" @click="edit(scope.row,scope.$index)"><i class="el-icon-edit"></i></el-button></span>
</template>
</el-table-column>
</el-table>
<script>
export default {
data(){
return{
editable:[],
table:[
{
date: '2016-05-03',
name: '王小虎',
province: '上海',
city: '普陀区',
address: '上海市普陀区金沙江路 123弄',
zip: 200333,
editflag:false
},
...........
]
}
},
methods:{
edit(row,index){
this.editable[index]=1;
console.log(this.editable)
},
}
}
</script> 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询