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

编程入门 行业动态 更新时间:2024-10-24 18:28:54

TODO Vue <a href=https://www.elefans.com/category/jswz/34/1771354.html style=typescript forEach的bug,需要再核實"/>

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 = taskform.value.invoiceSendEmail = falseform.value.invoicePrint = falseform.value.statementSendEmail = falseform.value.statementPrint = falseform.value.courierPrint = falseif (_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 DictionaryItemsys_dic_client.value.forEach((_dic: DictionaryItem) => {if (_dic.code == code && _dic.value == value) {dic = _dic}})return dic
}

更多推荐

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

本文发布于:2023-12-07 01:47:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1669700.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:typescript   Vue   TODO   再核實   bug

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!