赞
踩
后端接口
@Autowired
BlogService blogService;
@GetMapping("/blogs")
public Result list(@RequestParam(defaultValue = "1") Integer currentPage) {
Page page = new Page(currentPage, 5);
IPage pageData = blogService.page(page, new QueryWrapper<Blog>().orderByDesc("created"));
return Result.success(pageData);
}
接口测试
vue代码
<script>
export default {
data() {
return {
blogslist: {},
currentPage: 2,
total: 0,
pageSize: 5
}
},
created() {
this.getBlogsList()
},
methods: {
async getBlogsList() {
//1.得不到结果
const { data: res } = await this.$http.get('blogs', { params: this.currentPage })
//2.可以得到结果
const { data: res } = await this.$http.get('blogs?currentPage=' + this.currentPage)
console.log(res)
}
}
}
</script>
为什么1得到的结果师currentPage=1时的结果?
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。