首页 > 其他分享 >ant-select数据会发生卡顿问题解决

ant-select数据会发生卡顿问题解决

时间:2023-05-09 16:33:14浏览次数:36  
标签:current return pageSize debounce ant select 卡顿 searchPorjectList porjectList

        <a-select
          v-model="form.region"
          show-search
          placeholder="请选择"
          option-filter-prop="children"
          @search="handleSearch"
          @popupScroll="handlePopupScroll"
        >
          <a-select-option
            v-for="item in renderedPorjectList"
            :key="item.id"
            :value="item.id"
          >
            {{ item.name }}</a-select-option
          >
        </a-select>
<script>
import { getProjectsQ } from "@/api/market";
import debounce from "lodash/debounce";
export default {
  data() {
    return {
      form: {},
// 当前页
      current: 1,
      // 每页多少条
      pageSize: 10,
      // 所有的数据
      porjectList: [],
      // 符合条件的数据
      searchPorjectList: [],
    };
  },
  computed: {
    totalPage() {
      return Math.ceil(this.porjectList.length / this.pageSize);
    },
    // 展示在下拉框的数据
    renderedPorjectList() {
      return this.searchPorjectList.slice(0, this.pageSize * this.current);
    },
  },
  created() {
this.getProjectsQList();
  },
  methods: {
    handleSearch(value) {
      this.searchPorjectList = this.porjectList.filter((item) =>
        item.name.includes(value)
      );
    },
    // 滚动时触发
    handlePopupScroll: debounce(function () {
      if (this.totalPage >= this.current + 1) {
        this.current = this.current + 1;
      }
    }, 400),
    getProjectsQList() {
      getProjectsQ().then((res) => {
        this.porjectList = res.data;
        this.searchPorjectList = this.porjectList;
      });
    },
};
</script>
 

标签:current,return,pageSize,debounce,ant,select,卡顿,searchPorjectList,porjectList
From: https://www.cnblogs.com/hwy6/p/17385486.html

相关文章

  • Linux之select、poll、epoll讲解
    目录1select、poll、epoll1.1引言1.2IO和Linux内核发展1.2.1整体概述1.2.2阻塞IO1.2.3非阻塞IO1.2.4select1.2.5共享空间1.2.6零拷贝1.3select1.3.1简介1.3.2select缺点1.4poll介绍1.4.1与select差别1.4.2poll缺点1.5epoll1.5.1ep......
  • jquery select 操作
    //jQuery获取Select选择的Text和Value:varcheckText=jQuery("#select_id").find("option:selected").text();//获取Select选择的TextvarcheckValue=jQuery("#select_id").val();//获取Select选择的optionValuevarcheckIndex=jQuery("#sel......
  • Laf Assistant:云开发从未如此爽快!
    原文链接:https://forum.laf.run/d/67工欲善其事,必先利其器。在编写代码时,IDE也是我们不可或缺的。它可以让我们更高效地完成代码编写,提高开发效率。因此,IDE是我们编写代码中最亲密的伙伴之一。虽然Laf云开发有简洁的WebIDE,只要能打开浏览器就可以随处编辑云函数。但很......
  • 外汇天眼:Vantage获得FSCA许可,Plus500打算美国上市提振市值!
    在过去的一周,国外外汇市场上出现了一些倍受交易者关注的新闻,比如Vantage获得FSCA许可在南非运营、Plus500打算在美国股票上市以提振估值。具体新闻如下:1、Vantage获得FSCA许可在南非运营近期全球多资产经纪商Vantage宣布,它已获得南非金融部门行为监管局(FSCA)颁发的衍生品许可证。F......
  • Keycloak: Requesting Token with Password Grant
    Keycloak:RequestingTokenwithPasswordGranthttps://www.appsdeveloperblog.com/keycloak-requesting-token-with-password-grant/Inthistutorial,youwilllearnhowtouseaPasswordGrantOAuth2authorizationflowtorequestanAccessTokenandaRefre......
  • Keycloak: Authorization Code Grant Example
    Keycloak:AuthorizationCodeGrantExamplehttps://www.appsdeveloperblog.com/keycloak-authorization-code-grant-example/ 适合web应用 Inthistutorial,youwilllearnhowtogetanaccesstokenfromtheKeycloakauthorizationserverusingtheOAuthAuthor......
  • vant list列表 滑动加载
    瀑布流滚动加载,用于展示长列表,当列表即将滚动到底部时,会触发事件并加载更多列表项。importVuefrom'vue';import{List}from'vant';Vue.use(List);<van-listv-model="loading":finished="finished"finished-text="没有更多了"@load="onLoad&quo......
  • CodeForces - 630F Selection of Personnel (组合数学)
    TimeLimit: 500MS MemoryLimit: 65536KB 64bitIOFormat: %I64d&%I64uCodeForces-630FSelectionofPersonnelSubmit StatusDescriptionOnecompanyofITCitydecidedtocreateagroupofinnovativedevelopmentsconsistingfrom 5 to 7 peopleandhir......
  • 解决antd form表单校验错误时,设置scrollToFirstError 不能滚动到第一个校验错误位置
    使用antdform表单自带属性scrollToFirstError校验不通过时自动滚动到第一个校验错误位置,但是经常没有效果,手动添加一个滚动方法来处理//表单滚动到第一个报错处(antd)exportconstscrollToFirstError=()=>{document.querySelector('.ant-form-item-has-error')?.scro......
  • react + antd table列表自动滚动
    /***@file:table列表自动滚动,鼠标划入滚动暂停,鼠标划出滚动继续*/const[dataSource,setDataSource]=useState([])const[timer,setTimer]=useState()useEffect(()=>{if(dataSource.length){autoScroll(dataSource)}return()=>cl......