The current page property of the Pagination component in element-UI does not update the pit of the view synchronously
1. The location of the pit
When I was writing a page, I used the Element-UI pagination component. The effect was that as the page number changed, the page would send a request for the corresponding page number to obtain the corresponding data. Here is the code I wrote at that time:
Here’s the data from data:
Note: this is when the problem arises; When I click the page number button of the paging component to change the current page and re-send the request, I find that the page number is changed, but there is no request for the corresponding page.
2. Causes and solutions of the problems
Later I looked through the materials and found there was a hole. Let’s take a look at the official document:Stated in the official documentationcurrent-page
Bind anumber
Type, so now you know why I couldn’t send the request after PRESSING the page number button:
This problem occurred when I simply assigned the object’s attributes to the current-page property because I wanted to be lazy about writing a few variables.
Reason: The current page property of the Element-UI paging component can only be bound to variables of the base number type, not to variables represented as objects, because it has no way of listening for changes to specific properties within an object.
The curren-Page property has no way to bind variables in the form of an object, so we can use each intermediate variable to receive the internal value of the object, keep the intermediate variable in sync with the internal value of the object, and assign the intermediate variable to the curren-Page property: