第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

vue的分頁我一共獲取了total=12條數(shù)據(jù)每頁設(shè)置顯示10條,為什么點(diǎn)擊第二個(gè)頁碼的時(shí)候是沒有

vue的分頁我一共獲取了total=12條數(shù)據(jù)每頁設(shè)置顯示10條,為什么點(diǎn)擊第二個(gè)頁碼的時(shí)候是沒有

呼啦一陣風(fēng) 2019-03-28 15:19:49
<template><el-main><h1>學(xué)校通知</h1><ul>  <li v-for='news in tableData'><router-link :to="'/schoolnotice/'+news.newsID">{{news.title}}</router-link><span>{{news.publishTime}}</span></li></ul>        **分頁**<el-pagination  layout="prev, pager, next"  :total="total"  :page-size="10"  @current-change="handleCurrentChange"></el-pagination></el-main></template><script>export default {data() {return {  newsList:[],  total:{},  tableData: [], //表格顯示數(shù)據(jù)  allData: [], //總數(shù)據(jù)}},**獲取數(shù)據(jù)**mounted () {const that = this;console.log(that);this.$http.get(  that.$interface+'getArticlePages?categoryId=2')  .then(function (response) {    if(response.data.status === 1){      response.data.data.list.forEach(function(item){        that.allData.push({          title:item.title,          publishTime:item.publishdate,          newsID:item.articleid,        });        that.total = response.data.data.total;                    **從allData獲取數(shù)據(jù)到tableData**         that.tableData = that.allData.slice(0, 10);        console.log(that.total);      });    }else{      that.$message({        message: response.data.msg,        type: 'warning'      });    }  })  .catch(function (err) {    console.log(err);    that.$message({      message: '數(shù)據(jù) error',      type: 'warning'    })  });}, 頁碼點(diǎn)擊事件methods:{handleCurrentChange(val) {  //當(dāng)前頁  console.log(val);  this.tableData = this.allData.slice((val - 1) * 10, 10 * val);}}
查看完整描述

5 回答

?
莫回?zé)o

TA貢獻(xiàn)1865條經(jīng)驗(yàn) 獲得超7個(gè)贊

  1. 找你們后端,如果是做前端分頁讓他返回所有數(shù)據(jù),也很可能是后端分頁而你們沒對清楚接口

    response.data.data.list.forEach(function(item){
         ...
         console.log(that.total);//打印了10次12 意思是list長度本來就是10});
  2. 為什么要在list.forEach里面push,如果你只是想格式化數(shù)組用map。更不要在forEach里重復(fù)的執(zhí)行無用的 that.total = ... that.tableData = ...,10次循環(huán)前面9次都是無用的賦值。


查看完整回答
反對 回復(fù) 2019-04-03
?
qq_遁去的一_1

TA貢獻(xiàn)1725條經(jīng)驗(yàn) 獲得超8個(gè)贊

切換到第二頁的時(shí)候,檢查下tableData是不是剩下的那兩條數(shù)據(jù)


查看完整回答
反對 回復(fù) 2019-04-03
?
慕田峪7331174

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超13個(gè)贊

------------ update

撤回之前的回答, 我看錯(cuò)了。汗

會(huì)不會(huì)接口返回的就是 10條數(shù)據(jù)?


查看完整回答
反對 回復(fù) 2019-04-03
?
胡說叔叔

TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超8個(gè)贊

看一下你的allData是多少條數(shù)據(jù)


查看完整回答
反對 回復(fù) 2019-04-03
?
慕桂英546537

TA貢獻(xiàn)1848條經(jīng)驗(yàn) 獲得超10個(gè)贊

應(yīng)該后臺(tái)接口有問題,totallist不匹配


查看完整回答
反對 回復(fù) 2019-04-03
  • 5 回答
  • 0 關(guān)注
  • 10068 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)