在每次调用getDic()函数之前,可以先清空refundStatus数组,避免重复添加选项。可以修改代码如下:

function getDic() {
  loading.value = true;
  dictonaryStore
    .getDicData("refund_status")
    .then((data: DicDataPageVO[]) => {
      console.log(data);
      //按isdefault排序
      refundStatus = data; // 清空refundStatus数组并赋值为新的数据
      //第一个Y作为默认值
    })
    .catch((err) => {
      console.log(err);
    })
    .finally(() => {
      loading.value = false;
    });
  loading.value = true;
}

这样每次调用getDic()函数时,都会先清空refundStatus数组并重新赋值为新的数据

function getDic loadingvalue = true; dictonaryStore getDicDatarefund_status thendata DicDataPageVO = consolelogdata; 按isdefault排序 refundStatuspushdata; 第一个Y作为默认值 c

原文地址: https://www.cveoy.top/t/topic/iM1L 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录