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
}
相关推荐
我命由我1234516 小时前
微信小程序开发 - 为 tap 事件的处理函数传递数据
开发语言·前端·javascript·微信小程序·小程序·前端框架·js
百万蹄蹄向前冲20 小时前
Trae Genimi3跟着官网学实时通信 Socket.io框架
前端·后端·websocket
狂炫冰美式21 小时前
TRAE SOLO 驱动:重构AI模拟面试产品的复盘
前端·后端·面试
1024肥宅1 天前
JavaScript 拷贝全解析:从浅拷贝到深拷贝的完整指南
前端·javascript·ecmascript 6
欧阳天风1 天前
js实现鼠标横向滚动
开发语言·前端·javascript
局i1 天前
Vue 指令详解:v-for、v-if、v-show 与 {{}} 的妙用
前端·javascript·vue.js
码界奇点1 天前
Java Web学习 第15篇jQuery从入门到精通的万字深度解析
java·前端·学习·jquery
小鑫同学1 天前
Alias Assistant:新一代 macOS Shell 别名管理解决方案
前端·前端工程化
꒰ঌ小武໒꒱1 天前
RuoYi-Vue 前端环境搭建与部署完整教程
前端·javascript·vue.js·nginx
名字越长技术越强1 天前
前端之相对路径
前端