This article mainly introduces how Vue2.5 combines the Table and Pagination components of Element UI to realize the paging function. It is very good and has reference value. Friends in need can refer to it
It’s the end of 2017, summary In the past year or so of the front-end road, Vue has gone from getting started to giving up, then entering the palace for the second time, and has continued to track from Vue1.0 to Vue2.5. Combined with some actual projects of the company, some more practical components are also encapsulated.
Since the current company management platform mainly uses Element UI, we simply combined the components Table and Pagination to encapsulate a Table component that supports page switching. No verbosity, just enter the code directly.
main .js
// Element UI import Element from 'element-ui' // 默认样式 import 'element-ui/lib/theme-chalk/index.css'
Since the company's projects all start with i, in order to distinguish components and pages, it is customary Component names also start with i. First, add the Table and Pagination components
Develop a good habit of writing comments. The amount of comments for personal projects will basically not be less than 30%
In addition to the columns parameter and the operators parameter, the other parameters should be easy to understand, okay. Then we will explain these two parameters in detail, then we need to combine the component iTable.vue to explain. Next, we will add muscles and blood vessels to iTable.vue, and the codes are posted. What is more difficult to understand is the render parameter in columns, which uses Vue's virtual tags in order to be able to use various html tags and other components of element UI in the columns of the table as desired. (You can also write it directly and see if the table component can be recognized, hahaha!) This is probably a difficult place to understand for those who are just getting started. For more details, you can first look at vue's render for a clearer explanation. , If some friends don’t understand, you can send me a private message directly~~~
{{scope.row[column.prop]}}
{{ btn.label }} 筛选过滤
表格操作
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
NavigatorIOS component in React Native (detailed tutorial description)
About how to use ejsExcel template
How to create a logistics map in D3.js (detailed tutorial)
The above is the detailed content of How to implement paging function through Table and Pagination components in Vue2.5. For more information, please follow other related articles on the PHP Chinese website!