1. 参数拼接
/*** 数据查询*/const handleQuery = ( params: any) = > { loading.value = true ; axios.get( "/ebook/list?page=" +params.page+"&size=" +params.size) .then(( response) = > { loading.value = false ; const data = response.data; ebooks.value = data.content.list; // 重置分页按钮pagination.value.current = params.page; //总条数pagination.value.total = data.content.total; } ) ; } ;
2. 查询对象对象封装
/*** 数据查询*/const handleQuery = ( params: any) = > { loading.value = true ; axios.get( "/ebook/list" , { params: { page: params.page,size: params.size} } ) .then(( response) = > { loading.value = false ; const data = response.data; ebooks.value = data.content.list; // 重置分页按钮pagination.value.current = params.page; //总条数pagination.value.total = data.content.total; } ) ; } ;