element ui 下拉框分页

2021-09-27  本文已影响0人  戒烟少年
<template>
<el-select v-model="valueuser" placeholder="请选择用户" class="interval" @change="selectuser">
   <el-option
      v-for="item in userlist"
      :key="item.userId"
      :label="item.username"
      :value="item.userId">
    </el-option>
    <el-pagination
       @size-change="handleSizeChange"
       @current-change="handleCurrentChange"
       :current-page.sync="currentPage"
       :page-size="pagesize"
       layout="total, prev, pager, next"
       :total="totalnum">
    </el-pagination>
  </el-select>
</template>

<script>
export default {
  data() {
    return {
      valueuser:"",
      userlist:[],
      //分页
      currentPage: 1,
      pagesize:10,
      totalnum:50,
    };
  },
  mounted() {
   this.getalluserid();
  },
  getalluserid(){
       this.$http
           .get(`你请求的接口地址` {
           })
           .then(res => {
              // console.log(res.data)
               //this.userlist=res.data;
               this.valueuser=res.data.userId;
               this.totalnum=res.data.length;
               console.log(this.totalnum);
               this.userlist=res.data;
           });
   },
   handleSizeChange(val) {
       //console.log(`每页 ${val} 条`);
       this.pagesize=val;
    },
   handleCurrentChange(val) {
       //console.log(`当前页: ${val}`);
       this.currentPage=val;
   this.getalluserid();
   }
}
</script>
上一篇下一篇

猜你喜欢

热点阅读