程序问答   发布时间:2022-06-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了当列表返回 404 错误时,它会做什么?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决当列表返回 404 错误时,它会做什么??

开发过程中遇到当列表返回 404 错误时,它会做什么?的问题如何解决?下面主要结合日常开发的经验,给出你关于当列表返回 404 错误时,它会做什么?的解决方法建议,希望对你解决当列表返回 404 错误时,它会做什么?有所启发或帮助;

= 查找和降序 尽管我在单击标题时调用了对 onClick 方法进行排序的函数

我编辑了我的代码以显示 customerList 和 countercount 的来源

解决方法

这是否有帮助:

const base_customerList = [{"ID":1,"name":"Queen","email":"Queen@gmail.com","counts_of_visit":13,"latest_time_of_visit":"2021-03-12T12:08:23.000Z","contacted":"Yes"},{"ID":2,"name":"Jack","email":"Jack@gmail.com","counts_of_visit":2,"latest_time_of_visit":"2021-04-30T02:08:23.000Z",{"ID":3,"name":"Nolan","email":"Nolan@gmail.com","counts_of_visit":6,"contacted":"No"},{"ID":4,"name":"Janet","email":"Janet@gmail.com","counts_of_visit":7,{"ID":5,"name":"Loris","email":"Loris@gmail.com","counts_of_visit":8,{"ID":6,"name":"Bree","email":"Bree@gmail.com","counts_of_visit":3,{"ID":7,"name":"Daphne","email":"Daphne@gmail.com","latest_time_of_visit":"2021-04-15T09:08:23.000Z",{"ID":8,"name":"Bari","email":"Bari@gmail.com","counts_of_visit":4,{"ID":9,"name":"Billy","email":"Billy@gmail.com","counts_of_visit":5,{"ID":10,"name":"Belia","email":"Belia@gmail.com",{"ID":11,"name":"Moses","email":"Moses@gmail.com","counts_of_visit":9,{"ID":12,"name":"Alex","email":"Alex@gmail.com","latest_time_of_visit":"2021-02-10T01:08:23.000Z",{"ID":13,"name":"Alix","email":"Alix@gmail.com",{"ID":14,"name":"Wendell","email":"Wendell@gmail.com",{"ID":15,"name":"Ceola","email":"Ceola@gmail.com","contacted":"No"}];


const Table = () => {
  const [counterCount,setCounterCount] = React.useState(3);
  const [customerList,setCustomerList] = React.useState(base_customerList);
  
  function sortCountCustomer() {
    const sortedCountCustomer = [...base_customerList];
    let sortCountVisit = counterCount;

    if (sortCountVisit === 3) {
      sortCountVisit = 1;
      setCountercount(1);
    } else {
      sortCountVisit += 1;
      setCounterCount(sortCountVisit);
    }

    if (sortCountVisit < 3)
      sortedCountCustomer.sort(function (x,y) {
        if (sortCountVisit === 1) {
          return x.counts_of_visit - y.counts_of_visit;
        } else if (sortCountVisit === 2) {
          return y.counts_of_visit - x.counts_of_visit;
        }
      });
    
    setCustomerList(sortedCountCustomer);
  }
  
  return (<table>
    <thead>
      <tr>
        <th>Name</th>
        <th onClick={() => sortCountCustomer()}>
          Counts of Visit
        </th>
      </tr>
    </thead>
    <tbody>
      {CustomerList.map((C) => (
        <tr key={C.ID}>
          <td>{ c.name }</td>
          <td>{ c.counts_of_visit }</td>
        </tr>
      ))}
    </tbody>
  </table>);
};

const App = () => <Table />;
ReactDOm.render(<App />,document.getElementById('root'));
<script crossorigin src="https://unpkg.com/react@17/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>
<div id="root"></div>

大佬总结

以上是大佬教程为你收集整理的当列表返回 404 错误时,它会做什么?全部内容,希望文章能够帮你解决当列表返回 404 错误时,它会做什么?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。