In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-11-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how vue3.0 manually encapsulates paging components, and the content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
The details are as follows
1. Parent component introduction
Src/views/goods/components/goods-comment.vue
/ / adjust the interface import {findCommentListByGoods} from'@ / api/product.js' export default {setup () {/ / filter condition prepare const reqParams = reactive ({/ / current page number page: 1, / / number of entries per page pageSize: 10, / / whether there is a picture hasPicture: null, / / filter condition tag: null / / sorted fields sortField: null}) / / changes in listening parameters watch (reqParams, () = > {findCommentListByGoods (goods.value.id, reqParams) .then (ret = > {total.value = ret.result.counts list.value = ret.result.items})} {immediate: true}) / / controls the change of page numbers const changePage = (page) = > {/ / modify paging parameters Re-invoke the interface to reqParams.page = page} 2. Sub-component
Src/components/library/xtx-pagination.vue
Previous page. {{item}}. Next page import {computed, ref} from 'vue'export default {name:' XtxPagination', props: {total: {type: Number, default: 80}, pagesize: {type: Number, default: 10} / / default initial page number / / page: {/ / type: Number, / / default: 1 / /}, setup (props, {emit) Attrs}) {/ / attrs represents the properties passed by the parent component But props does not receive properties This attribute is not responsive / / dynamic page number information / / number of pages per page / / const pagesize = 8 / / total number of pages let pages = Math.ceil (props.total / props.pagesize) / / current page number / / console.log (attrs.page) const currentPage = ref (attrs.page | | 1) / / dynamic page number list const list = computed () = > {/ / when the value of the total passed by the parent component changes The calculation attribute recalculates pages = Math.ceil (props.total / props.pagesize) const result = [] / / the total page number is less than or equal to 5 Greater than 5 if (pages
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.