这段代码本身已经比较简洁了,但是可以考虑以下优化:

  1. 使用 async/await 替代 Promise.then(),使代码更易读:
const { data: coreRole } = await getCoreRoleConfigList({ type: '1' });
  1. 对于只有一个参数的箭头函数,可以省略括号和 return,使代码更简洁:
const { data: coreRole } = await getCoreRoleConfigList({ type: '1' });

综上所述,最终代码如下:

const { data: coreRole } = await getCoreRoleConfigList({ type: '1' });
const coreRole = await getCoreRoleConfigList type 1 thenres = resdata;这个可以怎么优化

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

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