国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

vue項目實現分頁效果

瀏覽:85日期:2022-10-02 08:50:30

vue項目中實現分頁效果,供大家參考,具體內容如下

1.這里我們使用element-ui來實現,先使用npm安裝

npm i element-ui -S

2.在main.js中全局引入

import ElementUI from 'element-ui'import ’element-ui/lib/theme-chalk/index.css’Vue.use(ElementUI) //將element-ui掛在到全局

3.封裝組件

<template> <div class='block'> <el-pagination @current-change='handleCurrentChange' :current-page='currentPage' :page-size='6' layout='prev, pager, next, jumper' :total='total' :pager-count='5' > </el-pagination> </div></template><script>export default { props: ['num', 'page'], //傳入的總條數,和頁碼 data() { return {}; }, computed: { currentPage: function() { return this.page; }, total: function() { return this.num; } }, methods: { handleSizeChange(val) { this.$emit('size-change', val); }, handleCurrentChange(val) { this.$emit('current-change', val); } }};</script><style>.block { text-align: right; /* width: 100%; */}</style>

4.引入組件并使用

<template> <div class='mobild'> <div> <ATablePaging :num='num' :page='page' @current-change='(val) => { page = val; list(); }' ></ATablePaging> </div> </div></template><script>import ATablePaging from '../paging'; //引入分頁組件export default { data() { return { page:'', //當前頁碼 num: 1, //內容總條數 }; }, methods: { list() { //發送的http請求 //后端返回的總頁數等于num }, }, mounted() { this.news(); }, components: { ATablePaging }};</script><style scoped></style>

關于vue.js的學習教程,請大家點擊專題vue.js組件學習教程、Vue.js前端組件學習教程進行學習。

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。

標簽: Vue
相關文章:
主站蜘蛛池模板: 万荣县| 黎城县| 沅陵县| 大姚县| 乐东| 确山县| 和顺县| 武安市| 吴川市| 丰原市| 广宗县| 呼和浩特市| 南澳县| 新田县| 上犹县| 乐平市| 神池县| 阿拉善盟| 革吉县| 北宁市| 黄平县| 昌邑市| 合水县| 古丈县| 青川县| 泊头市| 尖扎县| 根河市| 五河县| 新密市| 沾化县| 砀山县| 南投市| 西充县| 肇源县| 邓州市| 长岭县| 天全县| 六安市| 鹿邑县| 徐汇区|