React中的分页不能正常工作

时间:2018-01-08 20:00:57

标签: javascript reactjs

我在REACT JS中创建了一个分页

Axios网址功能不起作用

  async PaginationlimitPerPage (begin, end, increase) {



    const _URL =`http://localhost:8888/get/material/${params.categoryID}"/${params.subcategoriaID}?page=${this.state.currentPage}`;

    console.log(_URL);


    await axios(_URL).then((response) => {

      console.log(response);

    this.setState ({
        materials: response.data.data.data,
        currentPage: this.state.currentPage + increase
      });
    }).catch((error) => {
      // Error
      if (error.response) {

           console.log("Error response", error.response.data);

      } else if (error.request) {
          // The request was made but no response was received
          // `error.request` is an instance of XMLHttpRequest in the browser and an instance of
          // http.ClientRequest in node.js
          console.log("Error request", error.request);
      } else {
          // Something happened in setting up the request that triggered an Error
          console.log('Error', error.message);
      }
  });

  }

不识别params传递,不要在控制台中显示任何错误,也不要在检查器中使用Debug显示_URL。

这是错误还是语法错误?

0 个答案:

没有答案