In this section we will show data by easytable.
1, the premise of restraint
Complete installation nodejs, vue-cli, webpack, webpack-dev-server of
https://www.jianshu.com/p/eb4d9e132f62
2, Procedure
- Vue scaffolding to create a project template and start successfully, assuming that the project name is EasyTable-vue
https://www.jianshu.com/p/644eb12a8174 - Download easytable of js package
cd vue-easytable
cnpm install vue-easytable --save-dev
- Modify main.js, add the following
import 'vue-easytable/libs/themes-base/index.css'
import {VTable, VPagination} from 'vue-easytable'
Vue.component(VTable.name, VTable)
Vue.component(VPagination.name, VPagination)
- Create a mock folder under the src folder, create a folder table.js in mock
export default [
{ 'id': '1', 'name': 'xiaoli' },
{ 'id': '2', 'name': 'jiangsu' },
{ 'id': '3', 'name': 'ali' },
{ 'id': '4', 'name': 'zhangli' },
{ 'id': '5', 'name': 'wanhe' },
]
- Modify HelloWorld.vue
<template>
<div class="tablePage">
<h1>表格+分页</h1>
<!-- 表格-->
<v-table
:columns="tableConfig.columns"
:table-data="tableConfig.tableData"
:paging-index="(pageIndex-1)*pageSize"
></v-table>
<!-- 分页-->
</div>
</template>
<script>
import tableData from '../mock/table.js'
export default {
name: 'db',
data () {
return {
pageIndex: 1,
pageSize: 10,
total: '',
tableConfig: {
tableData: [],
columns: [
{
field: 'id',
title: '编号',
width: 50,
columnAlign: 'center'
},
{
field: 'name',
title: '姓名',
width: 120,
columnAlign: 'center'
}
]
}
}
},
created () {
this.getTableData()
},
methods: {
query () {
this.tableConfig.tableData = tableData;
}
},
mounted () {
this.query()
}
}
</script>
- Compile and start
npm run build
npm run dev
Prompt access url, will be able to see the form displayed no concern centered [I]:
The above is in the process of easytable vue project by displaying the data.