久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

vue項(xiàng)目實(shí)現(xiàn)分頁(yè)效果

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

vue項(xiàng)目中實(shí)現(xiàn)分頁(yè)效果,供大家參考,具體內(nèi)容如下

1.這里我們使用element-ui來(lái)實(shí)現(xiàn),先使用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'], //傳入的總條數(shù),和頁(yè)碼 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'; //引入分頁(yè)組件export default { data() { return { page:'', //當(dāng)前頁(yè)碼 num: 1, //內(nèi)容總條數(shù) }; }, methods: { list() { //發(fā)送的http請(qǐng)求 //后端返回的總頁(yè)數(shù)等于num }, }, mounted() { this.news(); }, components: { ATablePaging }};</script><style scoped></style>

關(guān)于vue.js的學(xué)習(xí)教程,請(qǐng)大家點(diǎn)擊專題vue.js組件學(xué)習(xí)教程、Vue.js前端組件學(xué)習(xí)教程進(jìn)行學(xué)習(xí)。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Vue
相關(guān)文章:
主站蜘蛛池模板: 综艺| 井冈山市| 丰宁| 鲜城| 托里县| 钟山县| 辽阳县| 萨迦县| 龙里县| 武川县| 浙江省| 清水河县| 桐城市| 南阳市| 尼勒克县| 黔西县| 上林县| 梅河口市| 维西| 进贤县| 靖江市| 黔西县| 玉屏| 辉县市| 琼结县| 南安市| 乌审旗| 鹿邑县| 精河县| 阳原县| 东台市| 五华县| 永济市| 松溪县| 玉环县| 高阳县| 绥德县| 石屏县| 双柏县| 金阳县| 钟山县|