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
}
相关推荐
仅此,13 分钟前
前端接收了id字段,发送给后端就变了
java·前端·javascript·spring·typescript
Lovely Ruby15 分钟前
[前端] 封装一下 echart 6,发布到 npm
前端·npm·node.js
BD_Marathon16 分钟前
NPM_常见命令
前端·npm·node.js
绿鸳19 分钟前
12.17面试题
前端
Huanzhi_Lin33 分钟前
禁用谷歌/google/chrome浏览器更新
前端·chrome
咸鱼加辣37 分钟前
【前端的crud】DOM 就是前端里的“数据库”
前端·数据库
kong790692840 分钟前
环境搭建-运行前端工程(Nginx)
前端·nginx·前端工程
成都证图科技有限公司1 小时前
Bus Hound概述
前端
PythonFun1 小时前
WPS中表格行高无法手动调整怎么办?
前端·html·wps
ttod_qzstudio1 小时前
DriveLerpControllerEditor开发总结:一个3D编辑器插值控制系统的实现
vue.js·typescript·编辑器·tdesign