2021-09-28有關(guān)于分頁的寫法

之前在分頁這么一直不知道該怎么去寫,然后上一次問了丑丑蒜埋,然后他給我一解釋淫痰,我好像就會寫了,下面就是具體得寫法整份,

頁面代碼:

?<div?class="newsList">

??????<div?class="Journalism">

????????<div?class="title"?style="font-size:?24px;?height:?44px">

??????????NEWS?INFORMATION

????????</div>

????????<div?class="title"?style="font-size:?40px;?line-height:?72px">

??????????新聞資訊

????????</div>

????????<div?class="more"?@click="seeMore">

??????????<span>/</span>

??????????<span>了解更多</span>

??????????<img?src="@/assets/images/newImg/home/more.png"?alt=""?/>

????????</div>

????????<div?class="newsBox">

??????????<el-row>

????????????<el-col?:span="12"?style="padding-right:?30px">

??????????????<div?class="img-box">

????????????????<div?class="mask">

??????????????????<div>{{?newsData[0].BI_TITLE?}}</div>

??????????????????<div>{{?newsData[0].date?}}</div>

????????????????</div>

??????????????</div>

????????????</el-col>

????????????<el-col?:span="12">

??????????????<time-line

????????????????:newsData="newsData"

??????????????></time-line>

????????????</el-col>

??????????</el-row>

??????<el-pagination?background?layout="prev,?pager,?next"?:total="TOTAL"?:page-size='PageSizes'?:current-page.sync="currentPage"?class="pagination"?@current-change="handleSizeChange"></el-pagination>

//:page-size="PageSizes"表示的是一頁顯示多少條

//:current-page.sync="currentPage"表示的是顯示幾頁

????????</div>

??????</div>

????</div>

邏輯代碼:

?data()?{

????return?{

??????currentPage:?1,?//頁碼

??????PageSizes:?5,?//條數(shù)

??????TOTAL:?0, //一共多少條數(shù)據(jù)

}}

methods:{

????newsList()?{

???????const?data?=?new?FormData()

???????data.append(

?????????"json",

?????????JSON.stringify({

????????????BI_TYPE:?"0",

????????????PageIndexs:?this.currentPage, //告訴接口幾頁默認(rèn)是一頁

????????????PageSizes:?this.PageSizes, //告訴接口一頁返回幾條數(shù)據(jù)

????????}),

???????)

??????Api.newsList(data).then((res)?=>?{

????????//?console.log(res,"home11111");

????????let?newsData?=?res.data;

???????newsData.map((item)?=>?{

??????????//?console.log(item,"item");

??????????item.date?=?item.PUSH_DATE;

??????????item.id?=?item.ID;

??????????item.title?=?item.BI_TITLE;

??????????item.centent?=?item.BI_CONTENTS;

??????????item.TNS_IMGPATH?=?item.BI_IMAGEURL;

????????});

????????this.newsData?=?newsData;

????????this.TOTAL?=?Number(res.dataTotal);

????????//?console.log(this.TOTAL,?"this.TOTAL");

??????});

????},

???//?頁數(shù)變化

????handleSizeChange?(value)?{

??????this.currentPage?=?value

??????this.newsList()

????},

樣式代碼:

?.newsList?{

????width:?100%;

????padding:?100px?0;

????.Journalism?{

??????width:?1200px;

??????margin:?0?auto;

??????.title?{

????????height:?40px;

????????font-size:?36px;

????????font-family:?Source?Han?Sans?CN;

????????font-weight:?500;

????????color:?#000000;

????????display:?flex;

????????justify-content:?center;

??????}

??????.more?{

????????width:?100%;

????????height:?20px;

????????margin:?20px?0;

????????border-radius:?13px;

????????cursor:?pointer;

????????font-size:?14px;

????????font-family:?Microsoft?YaHei;

????????font-weight:?400;

????????color:?#21589d;

????????display:?flex;

????????align-items:?center;

????????justify-content:?flex-end;

????????span?{

??????????margin-right:?15px;

????????}

??????}

??????.newsBox?{

????????.img-box?{

??????????width:?100%;

??????????height:?360px;

??????????background:?url("../../../assets/images/newImg/home/news.png")

????????????no-repeat;

??????????background-size:?100%?100%;

??????????position:?relative;

??????????.mask?{

????????????position:?absolute;

????????????left:?0;

????????????right:?0;

????????????bottom:?0;

????????????height:?90px;

????????????padding:?20px?30px;

????????????background:?rgba(33,?88,?157,?0.6);

????????????>?div?{

??????????????font-size:?18px;

??????????????font-family:?Microsoft?YaHei,?Microsoft?YaHei-Regular;

??????????????font-weight:?400;

??????????????text-align:?left;

??????????????color:?#ffffff;

??????????????letter-spacing:?0px;

????????????}

??????????}

????????}

??????}

??????.JournalismBox?{

????????height:?452px;

????????margin-top:?40px;

????????background:?#ffffff;

????????box-shadow:?0px?0px?10px?0px?rgba(0,?0,?0,?0.06);

????????border-radius:?5px;

????????.JournalismUl?{

??????????display:?flex;

??????????justify-content:?space-between;

??????????flex-wrap:?wrap;

??????????padding:?0?30px;

??????????.JournalismLi?{

????????????width:?269px;

????????????height:?380px;

????????????cursor:?pointer;

????????????.title?{

??????????????height:?90px;

??????????????border-bottom:?1px?solid?#eeeeee;

??????????????display:?flex;

??????????????flex-direction:?column;

??????????????.titleTop?{

????????????????height:?35px;

????????????????font-size:?31px;

????????????????font-family:?Microsoft?YaHei;

????????????????font-weight:?400;

????????????????color:?#333333;

??????????????}

??????????????.titleBotm?{

????????????????margin-top:?6px;

????????????????height:?13px;

????????????????font-size:?14px;

????????????????font-family:?Microsoft?YaHei;

????????????????font-weight:?400;

????????????????color:?#999999;

??????????????}

????????????}

????????????.content?{

??????????????height:?107px;

??????????????margin-top:?20px;

??????????????.contentTitle?{

????????????????height:?48px;

????????????????font-size:?18px;

????????????????font-family:?Microsoft?YaHei;

????????????????font-weight:?bold;

????????????????color:?#333333;

????????????????line-height:?24px;

????????????????display:?flex;

????????????????justify-content:?center;

??????????????}

??????????????.contentBox?{

????????????????width:?265px;

????????????????height:?80px;

????????????????margin-top:?14px;

????????????????font-size:?14px;

????????????????font-family:?Microsoft?YaHei;

????????????????font-weight:?400;

????????????????color:?#666666;

????????????????line-height:?20px;

????????????????text-indent:?47px;

????????????????display:?-webkit-box;

????????????????-webkit-box-orient:?vertical;

????????????????-webkit-line-clamp:?4;

????????????????overflow:?hidden;

??????????????}

??????????????.contentImg?{

????????????????width:?266px;

????????????????height:?137px;

????????????????margin-top:?11px;

????????????????img?{

??????????????????width:?100%;

??????????????????height:?100%;

????????????????}

??????????????}

????????????}

??????????}

????????}

????????.MoreInformation?{

??????????margin-top:?10px;

??????????height:?70px;

??????????line-height:?70px;

??????????display:?flex;

??????????justify-content:?center;

??????????font-size:?16px;

??????????font-family:?Microsoft?YaHei;

??????????font-weight:?400;

??????????color:?#999999;

??????????cursor:?pointer;

????????}

??????}

????}

??}

后端接口數(shù)據(jù)的返回及傳參:


最后的效果展示如下:


?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
禁止轉(zhuǎn)載待错,如需轉(zhuǎn)載請通過簡信或評論聯(lián)系作者。
  • 序言:七十年代末烈评,一起剝皮案震驚了整個濱河市火俄,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌讲冠,老刑警劉巖瓜客,帶你破解...
    沈念sama閱讀 218,682評論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異竿开,居然都是意外死亡谱仪,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,277評論 3 395
  • 文/潘曉璐 我一進(jìn)店門德迹,熙熙樓的掌柜王于貴愁眉苦臉地迎上來芽卿,“玉大人揭芍,你說我怎么就攤上這事胳搞。” “怎么了?”我有些...
    開封第一講書人閱讀 165,083評論 0 355
  • 文/不壞的土叔 我叫張陵肌毅,是天一觀的道長筷转。 經(jīng)常有香客問我,道長悬而,這世上最難降的妖魔是什么呜舒? 我笑而不...
    開封第一講書人閱讀 58,763評論 1 295
  • 正文 為了忘掉前任,我火速辦了婚禮笨奠,結(jié)果婚禮上袭蝗,老公的妹妹穿的比我還像新娘。我一直安慰自己般婆,他們只是感情好到腥,可當(dāng)我...
    茶點故事閱讀 67,785評論 6 392
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著蔚袍,像睡著了一般乡范。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上啤咽,一...
    開封第一講書人閱讀 51,624評論 1 305
  • 那天晋辆,我揣著相機與錄音,去河邊找鬼宇整。 笑死瓶佳,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的没陡。 我是一名探鬼主播涩哟,決...
    沈念sama閱讀 40,358評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼盼玄!你這毒婦竟也來了贴彼?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,261評論 0 276
  • 序言:老撾萬榮一對情侶失蹤埃儿,失蹤者是張志新(化名)和其女友劉穎器仗,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體童番,經(jīng)...
    沈念sama閱讀 45,722評論 1 315
  • 正文 獨居荒郊野嶺守林人離奇死亡精钮,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,900評論 3 336
  • 正文 我和宋清朗相戀三年检诗,在試婚紗的時候發(fā)現(xiàn)自己被綠了卵酪。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片越妈。...
    茶點故事閱讀 40,030評論 1 350
  • 序言:一個原本活蹦亂跳的男人離奇死亡顷编,死狀恐怖何鸡,靈堂內(nèi)的尸體忽然破棺而出颊糜,到底是詐尸還是另有隱情嗅剖,我是刑警寧澤范删,帶...
    沈念sama閱讀 35,737評論 5 346
  • 正文 年R本政府宣布,位于F島的核電站脓杉,受9級特大地震影響糟秘,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜球散,卻給世界環(huán)境...
    茶點故事閱讀 41,360評論 3 330
  • 文/蒙蒙 一尿赚、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧蕉堰,春花似錦凌净、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,941評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至丑婿,卻和暖如春性雄,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背羹奉。 一陣腳步聲響...
    開封第一講書人閱讀 33,057評論 1 270
  • 我被黑心中介騙來泰國打工秒旋, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人诀拭。 一個月前我還...
    沈念sama閱讀 48,237評論 3 371
  • 正文 我出身青樓迁筛,卻偏偏與公主長得像,于是被迫代替她去往敵國和親耕挨。 傳聞我的和親對象是個殘疾皇子细卧,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,976評論 2 355

推薦閱讀更多精彩內(nèi)容