vue2中使用v-selectpage插件 搜索并分页

https://terryz.gitee.io/vue/#/selectpage

 

          <v-selectpage
              data="/api/intrusionevent/lists"
              v-model="temp.event_id"
              key-field="id"
              show-field="description"
              search-field="description"
              :result-format="selectResultFormat"
              :params="{ search: 1 }"
          >
          </v-selectpage>
 methods: {
    selectResultFormat(resp){
      const res = resp.data
      let obj = {
        totalRow:res.data.count,
        list:res.data.list
      }
      return obj
    },
}

 

main.js

import vSelectPage from 'v-selectpage'
Vue.use(vSelectPage, {
  // server side data loader
  dataLoad: function(vue, data, params) {
    const { pageNumber, pageSize, } = params;
    if (pageNumber) {
      params.page = pageNumber
      delete params.pageNumber
    }
    if (pageSize) {
      params.limit = pageSize
      delete params.pageSize
    }
    return new Promise((resolve, reject) => {
      axios.get(data, {params: params}).then(resp => resolve(resp), resp => reject(resp));
    });
  }
})

posted @ 2024-01-18 16:32  _迷途  阅读(219)  评论(0编辑  收藏  举报