我是Vue的新手.js和DataTable,我希望你们中的一些人有集成它们的经验..

	var app = new Vue({

	    el: '#root',

		data(){
		    return{
                employees: [
                    {
                        Name: 'Tiger Nixon',
                        Position: 'System Architect',
                        Office: 'tokyo',
                        Age: '61',
                        StartDate: '2011/04/25',
                        Salary: '$320,800',
                    },
                ],
                name: '',
                position: '',
                office: '',
                age: '',
                startDate: '',
                salary: '',
                dataTable: null
            }
		},

		methods: {
		    addEmployee(){
			  this.dataTable.row.add([
			      this.name,
			      this.position,
			      this.office,
			      this.age,
			      this.startDate,
			      this.salary,
			  ]).draw(false);
		    }
		},

		mounted(){
		    this.dataTable = $('#data_table').DataTable({

		    });
		}


	})
#root{
  text-align: center;
}

.btn{
  margin-bottom: 30px;
}
<div id="root" class="container">
	<form class="form-inline">
		<div class="form-group">
			<label for="name">Name:</label><br>
			<input type="text" v-model="name" class="form-control" id="name">
		</div>
		<div class="form-group">
			<label for="position">Position</label><br>
			<input type="text" v-model="position" class="form-control" id="position">
		</div>
		<div class="form-group">
			<label for="office">Office</label><br>
			<input type="text" v-model="office" class="form-control" id="office">
		</div>
		<div class="form-group">
			<label for="age">Age</label><br>
			<input type="text" v-model="age" class="form-control" id="age">
		</div>
		<div class="form-group">
			<label for="Start_date">Start Date</label><br>
			<input type="text" v-model="startDate" class="form-control" id="start_date">
		</div>
		<div class="form-group">
			<label for="salary">Salary</label><br>
			<input type="text" v-model="salary" class="form-control" id="salary">
		</div><br><br>
		<button type="button" @click="addEmployee" class="btn btn-primary">Submit</button>
	</form>
	<table id="data_table" class="display" cellspacing="0" width="100%">
		<thead>
		<tr>
			<th>Name</th>
			<th>Position</th>
			<th>Office</th>
			<th>Age</th>
			<th>Start Date</th>
			<th>Salary</th>
		</tr>
		</thead>
		<tbody>
		<tr v-for="employee in employees">
			<td>{{ employee.Name }}</td>
			<td>{{ employee.Position }}</td>
			<td>{{ employee.Office }}</td>
			<td>{{ employee.Age }}</td>
			<td>{{ employee.StartDate }}</td>
			<td>{{ employee.Salary }}</td>
		</tr>
		</tbody>
	</table>
</div>

<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.13/css/jquery.dataTables.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.13/js/jquery.dataTables.js"></script>
<script src="https://unpkg.com/vue@2.1.8/dist/vue.js"></script>

推荐答案

我更喜欢使用vuejs的桌子.

很快就可以开始使用,并且可以轻松地与bootstrap或语义ui框架集成.也有非常好的可定制的排序字段和搜索,以及从api获取数据,但这一部分需要从api中获得特定的数据响应格式,除非您对此没有太多控制,否则很难实现分页.

另一个 Select 是https://github.com/matfish2/vue-tables-2 我发现这个很难开始,因为它需要一些jsx设置,但它的 struct 比上面的第一个好.

UPDATE:vue-tables-2现在是预编译的,不需要任何转换或加载程序

老实说,我更喜欢上面的一个选项,或者如果你在awesome vue(github上的vue组件列表)上找到另一个组件的话.

除非您不需要pdf导出、样式表导出或花哨的打印内容,否则我不明白您为什么要使用数据表.

Vue.js相关问答推荐

带 Bootstrap 的 Vue js,导航栏菜单不起作用

Vuetify/Vue3 插槽模板之间的阴影

在预渲染模式下部署 nuxt 3 时出错

Vuetify右侧并排switch

VueJS 中的 VisJS 时间轴:带有图像的项目放错了位置

纵横比元素溢出容器

VueJS CKeditor5 上传图片

如何 for each 用户分组聊天消息?

Defer推迟执行,直到外部脚本加载到 Vue.js

apache上的Vue-router,子目录下的SPA,只能通过重定向访问页面

如何为 Vue 项目设置 lint-staged?

如何将 Nuxt.js 更新到最新版本

将 props 传递给 Vue 组件中的元素属性

将数据传递给另一条路由上的组件

从 Axios 响应中解析 XML,推送到 Vue 数据数组

vue组件中导入和使用three.js库

使用 Vue.js & DataTable(jquery 插件)

Vue CLI 3 sass-resources-loader - Options.loaders 未定义

如何从 Vuex 操作访问 Vuex 状态属性?

使用 svelte js 的原因