update Table cell

update Table cell
This commit is contained in:
梁灏 2017-03-09 16:03:36 +08:00
parent 87a400d85e
commit 3c38e4f7f1
2 changed files with 41 additions and 60 deletions

View file

@ -1,94 +1,75 @@
<template> <template>
<Table width="550" :content="self" border :columns="columns2" :data="data3"></Table> <Card>
<Table border :content="self" :columns="columns7" :data="data6"></Table>
</Card>
</template> </template>
<script> <script>
export default { export default {
name: 'vvv',
data () { data () {
return { return {
self: this, self: this,
columns2: [ columns7: [
{ {
title: '姓名', title: '姓名',
key: 'name', key: 'name',
width: 100, render (row, column, index) {
fixed: 'left' return `<Icon type="person"></Icon> <strong>${row.name}</strong>`;
}
}, },
{ {
title: '年龄', title: '年龄',
key: 'age', key: 'age'
width: 100
},
{
title: '省份',
key: 'province',
width: 100
},
{
title: '市区',
key: 'city',
width: 100
}, },
{ {
title: '地址', title: '地址',
key: 'address', key: 'address'
width: 200
},
{
title: '邮编',
key: 'zip',
width: 100
}, },
{ {
title: '操作', title: '操作',
key: 'action', key: 'action',
fixed: 'right', width: 150,
width: 120, align: 'center',
render () { render (row, column, index) {
return `<i-button type="text" size="small" @click.native="handleClick">查看</i-button><i-button type="text" size="small">编辑</i-button>`; return `<i-button type="primary" size="small" @click.native="show(${index})">查看</i-button> <i-button type="error" size="small" @click.native="remove(${index})">删除</i-button>`;
} }
} }
], ],
data3: [ data6: [
{ {
name: '王小明', name: '王小明',
age: 18, age: 18,
address: '北京市朝阳区芍药居', address: '北京市朝阳区芍药居'
province: '北京市',
city: '朝阳区',
zip: 100000
}, },
// { {
// name: '', name: '张小刚',
// age: 25, age: 25,
// address: '西', address: '北京市海淀区西二旗'
// province: '', },
// city: '', {
// zip: 100000 name: '李小红',
// }, age: 30,
// { address: '上海市浦东新区世纪大道'
// name: '', },
// age: 30, {
// address: '', name: '周小伟',
// province: '', age: 26,
// city: '', address: '深圳市南山区深南大道'
// zip: 100000 }
// },
// {
// name: '',
// age: 26,
// address: '',
// province: '广',
// city: '',
// zip: 100000
// }
] ]
} }
}, },
methods: { methods: {
handleClick () { show (index) {
console.log(123) console.log(`姓名:${this.data6[index].name}<br>年龄:${this.data6[index].age}<br>地址:${this.data6[index].address}`)
},
remove (index) {
this.data6.splice(index, 1);
} }
},
mounted () {
setTimeout(() => {
// this.data6.splice(2, 1);
}, 3000)
} }
} }
</script> </script>

View file

@ -60,7 +60,7 @@
this.$el.innerHTML = ''; this.$el.innerHTML = '';
let methods = {}; let methods = {};
Object.keys($parent).forEach(key => { Object.keys($parent).forEach(key => {
const func = this.$parent.$parent.$parent[`${key}`]; const func = $parent[`${key}`];
if (typeof(func) === 'function' && func.name === 'boundFn') { if (typeof(func) === 'function' && func.name === 'boundFn') {
methods[`${key}`] = func; methods[`${key}`] = func;
} }