you_do_what
you_do_what?
2021-01-23 17:11

请问后台写的分页查询前端怎么调用呢?

  • spring
  • vue.js
  • javascript
    @GetMapping(value = "/search/{currentPage}/{pageSize}")
    @Override
    public Result<PageInfo<T>> findByPage(@PathVariable(name = "currentPage") Integer currentPage,
                                          @PathVariable(name = "pageSize") Integer pageSize) {
        PageInfo<T> pageInfo = coreService.findByPage(currentPage, pageSize);
        return new Result<PageInfo<T>>(true, StatusCode.OK, "分页查询成功", pageInfo);
    }

前端是vue的,

var vue = new Vue({
        el: '#app',
        data: {
            autoUpload: true,//自动上传
            imageUrl: null,//模型数据,用于上传图片完成后图片预览
            activeName: 'first',//添加/编辑窗口Tab标签名称
            pagination: {//分页相关属性
                currentPage: 1,
                pageSize: 10,
                total: 100,
                queryString: null,
            },
            dataList: [],//列表数据
        },
        created() {
            this.findPage();
        },
        methods: {
            //分页查询
            findPage() {
                axios.post('/items/search.do', this.pagination).then(res => {
                    if (res.data.flag) {
                        this.dataList = res.data.data.rows;
                        this.pagination.total = res.data.data.total;
                    } else {
                        this.$message.error(res.data.message);
                    }
                })
            },
}

前端这里该怎么写才能完成将数据调出来?

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

5条回答

为你推荐