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
}
相关推荐
GIS之路1 分钟前
ArcGIS Pro 中的 Python 入门
前端
树獭非懒10 分钟前
告别繁琐多端开发:DivKit 带你玩转 Server-Driven UI!
android·前端·人工智能
兆子龙42 分钟前
当「多应用共享组件」成了刚需:我们从需求到模块联邦的落地小史
前端·架构
Qinana43 分钟前
从代码到智能体:MCP 协议如何重塑 AI Agent 的边界
前端·javascript·mcp
Wect1 小时前
LeetCode 130. 被围绕的区域:两种解法详解(BFS/DFS)
前端·算法·typescript
不会敲代码11 小时前
从入门到进阶:手写React自定义Hooks,让你的组件更简洁
前端·react.js
用户5433081441941 小时前
拆完 Upwork 前端我沉默了:你天天卷的那些技术,人家根本没用
前端
洋洋技术笔记1 小时前
Vue实例与数据绑定
前端·vue.js
Marshall1511 小时前
zzy-scroll-timer:一个跨框架的滚动定时器插件
前端·javascript
Dilettante2581 小时前
这一招让 Node 后端服务启动速度提升 75%!
typescript·node.js