在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ vue里我用el的分頁組件想實現(xiàn)一個功能,就是點擊第二頁的頁碼頁面上渲染上第二頁

vue里我用el的分頁組件想實現(xiàn)一個功能,就是點擊第二頁的頁碼頁面上渲染上第二頁的數(shù)據(jù),該怎么實現(xiàn)?(萬分感謝大佬們的諄諄教導!

<template>
  <el-main>
    <h1>學校通知</h1>
                             **// 渲染的數(shù)據(jù)頁面**
    <ul> 
      <li v-for='news in newsList'><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-page.sync="currentPage"
      @current-change="handleCurrentChange"
    >
    </el-pagination>
  </el-main>
</template>

<script>
export default {
  data() {
    return {
      newsList:[],
      total:{}
    }
  },
                           **//從后臺獲取的信息**
  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.newsList.push({
              title:item.title,
              publishTime:item.publishdate,
              newsID:item.articleid,
            });
            that.total = response.data.data.total;
            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'
        })
      });
  },
  methods:{
    handleCurrentChange(val) {
      this.currentPage = val;
      console.log(`當前頁: ${val}`);
    }
  }
}
</script>
回答
編輯回答
夏木

之前寫過一個小demo,你可以看看

2017年2月16日 20:27
編輯回答
傲嬌范

$http.get封裝成一個獲取第n頁的方法,點擊的時候執(zhí)行這個方法,請求完數(shù)據(jù)吧this.newsList替換為新的數(shù)據(jù),然后把頁碼也改到那一頁。

2017年9月19日 13:23