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 the project name for the Element-vue
https://www.jianshu.com/p/644eb12a8174 - Download the element-ui js package
cd vue-element
cnpm install element-ui --save-dev
- Modify main.js, add the following
import ElementUI from 'element-ui'
Vue.use(ElementUI)
- 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>
<!--相当于编写html的内容-->
<el-table
:data="tableData"
stripe
style="width: 100%">
<el-table-column
prop="id"
label="编号"
width="180">
</el-table-column>
<el-table-column
prop="name"
label="姓名"
width="180">
</el-table-column>
</el-table>
</div>
</template>
<script>
import tableData from '../mock/table.js'
export default {
data() {
return {
tableData: []
}
},
created () {
this.tableData = tableData;
}
}
</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 the process by project vue element-ui display data.