用iview 写 带分页的下拉框

需求

 

 

 Html部分

<Select
  v-model="name"
  clearable
  filterable
  @on-change="onChangeName"
  class="content_select2"
>
  <Option v-for="item in nameList" :value="item.id" :key="item.id">{{ item.name }}</Option>
  <Page
    :total="totalName"
    size="small"
    show-total
    :page-size="pageSizeName"
    :current="currentPageName"
    @on-change="handlePageName"
  />
</Select>

js部分

data() {
  return {
    name: '',
    nameList: [], // 机构列表
    totalName: 0, // 机构总数
    pageSizeName: 10, // 机构分页
    currentPageName: 1 // 机构分页
  }
},
methods: {
  onChangeType (val) {
    this.typeData = val
    this.handlePageName(1)
  },
  async handlePageName (val) {
    // 掉接口
    const { data, count } = await organizationController.cooperativeOrgani.getCooperative({
      type: this.typeData,
      pageSize: this.pageSizeName,
      pageNum: val
    })
    if (data) {
      this.nameList = data || []
      this.totalName = count
    } else {
      this.nameList = []
      this.totalName = 0
    }
  },
}

就是把下拉框里面加了个分页,很简单的东西

posted @ 2020-12-30 14:21  圆圆呀~  阅读(1172)  评论(0编辑  收藏  举报