我正在开发一个实现vue-tables-2的 vue 组件。我在这里有一个工作示例。我想要做的是将编辑 href url 链接到整行而不是仅编辑单元格。使用 vanilla javascript,我尝试使用mounted
钩子 ( this.$el
) 访问虚拟 dom 并将行包装在 href 中并隐藏编辑列,尽管感觉有点像 hack。关于如何做到这一点的任何建议?
<template>
<div class="col-md-8 col-md-offset-2">
<div id="people">
<v-client-table :data="tableData" :columns="columns">
<template slot="edit" slot-scope="props">
<div>
<a class="fa fa-edit" :href="edit(props.row.id)">thing</a>
</div>
</template>
</v-client-table>
</div>
</div>
</template>
<script>
import {ServerTable, ClientTable, Event} from 'vue-tables-2';
import Vue from 'vue';
import axios from 'axios';
export default {
methods: {
edit: function(id){
return "edit/hello-" + id
}
},
data() {
return {
columns: ['edit', 'id','name','age'],
tableData: [
{id:1, name:"John",age:"20"},
{id:2, name:"Jane",age:"24"},
{id:3, name:"Susan",age:"16"},
{id:4, name:"Chris",age:"55"},
{id:5, name:"Dan",age:"40"}
]
};
}
}
</script>