TODO Vue typescript forEach的bug,需要再核實

forEach 一個string[],只有最後一個匹配條件有效,其它條件無效。

所以,只能替換成普通的for循環。

复制代码
  console.log(taskList)
    // for (const _task of taskList.value) {
    //   if (_task == 'invoiceSendEmail') {
    //     form.value.invoiceSendEmail = true
    //   } else if (_task == 'invoicePrint') {
    //     form.value.invoicePrint = true
    //   } else if (_task == 'statementSendEmail') {
    //     form.value.statementSendEmail = true
    //   } else if (_task == 'statementPrint') {
    //     form.value.statementPrint = true
    //   } else if (_task == 'courierPrint') {
    //     form.value.courierPrint = true
    //   }
    // }

    taskList.value.forEach((task: string) => {
      let _task = ''
      _task = task
      form.value.invoiceSendEmail = false
      form.value.invoicePrint = false
      form.value.statementSendEmail = false
      form.value.statementPrint = false
      form.value.courierPrint = false

      if (_task == 'invoiceSendEmail') {
        form.value.invoiceSendEmail = true
      }
      if (_task == 'invoicePrint') {
        form.value.invoicePrint = true
      }
      if (_task == 'statementSendEmail') {
        form.value.statementSendEmail = true
      }
      if (_task == 'statementPrint') {
        form.value.statementPrint = true
      }
      if (_task == 'courierPrint') {
        form.value.courierPrint = true
      }
    })

    console.log(form)

以及通過forEach 返回時,沒有返回任何内容

必須重新賦值,才能返回 let dic = {} as DictionaryItem

复制代码
export const getDictionaryFromClient = (code: string, value: string) => {
  let dic = {} as DictionaryItem

  sys_dic_client.value.forEach((_dic: DictionaryItem) => {
    if (_dic.code == code && _dic.value == value) {
      dic = _dic
    }
  })
  return dic
}
相关推荐
未来龙皇小蓝10 分钟前
RBAC前端架构-02:集成Vue Router、Vuex和Axios实现基本认证实现
前端·vue.js·架构
晓得迷路了23 分钟前
栗子前端技术周刊第 116 期 - 2025 JS 状态调查结果、Babel 7.29.0、Vue Router 5...
前端·javascript·vue.js
biyezuopinvip28 分钟前
基于Spring Boot的企业网盘的设计与实现(毕业论文)
java·spring boot·vue·毕业设计·论文·毕业论文·企业网盘的设计与实现
顾北1238 分钟前
AI对话应用接口开发全解析:同步接口+SSE流式+智能体+前端对接
前端·人工智能
摸鱼的春哥1 小时前
春哥的Agent通关秘籍07:5分钟实现文件归类助手【实战】
前端·javascript·后端
念念不忘 必有回响1 小时前
viepress:vue组件展示和源码功能
前端·javascript·vue.js
C澒1 小时前
多场景多角色前端架构方案:基于页面协议化与模块标准化的通用能力沉淀
前端·架构·系统架构·前端框架
崔庆才丨静觅1 小时前
稳定好用的 ADSL 拨号代理,就这家了!
前端
江湖有缘1 小时前
Docker部署music-tag-web音乐标签编辑器
前端·docker·编辑器
恋猫de小郭2 小时前
Flutter Zero 是什么?它的出现有什么意义?为什么你需要了解下?
android·前端·flutter