美文网首页
this.$set 会跳出循环

this.$set 会跳出循环

作者: 细碎光芒 | 来源:发表于2020-08-06 21:54 被阅读0次

项目上遇到this.$set 会跳出循环的情况

问题先记录下来,后续更新原因

closeFlowTag (index, item) {
      this.reportUseList.splice(index, 1)
      this.thirdList.forEach((obj) => {
        let flow = obj.reportList.find((value, index, arr) => {
          return value.reportId === item.reportId
        })
       this.$set(flow, 'commonFlag', 'N')
      })
    },

这种情况下,flow无论有没有循环到值,都会走this.set,走this.set就会直接跳出循环,导致该循环只会走一次

closeFlowTag (index, item) {
      this.reportUseList.splice(index, 1)
      this.thirdList.forEach((obj) => {
        let flow = obj.reportList.find((value, index, arr) => {
          return value.reportId === item.reportId
        })
        if (flow) {
          this.$set(flow, 'commonFlag', 'N')
        }
      })
    },

this.$set会直接跳出循环的原因:

相关文章

  • this.$set 会跳出循环

    项目上遇到this.$set 会跳出循环的情况 问题先记录下来,后续更新原因 这种情况下,flow无论有没有循环到...

  • vue强制更新

    使用update this.$forceUpdate(),强制视图更新 用vue.set this.$set(th...

  • Vue 修改数组, 对象,生效

    this.$set(this.list, index, item); this.$forceUpdate()

  • this.$set

    this.$set(this.form, 'id', 'edit-' + data.id) (data值,key,...

  • 树形表使用懒加载后,更新的问题

    this.$set(this.$refs.tableData.store.states.lazyTreeNodeM...

  • vue的ref行间属性

    this.$refs : 获取到所有的元素带有行间属性ref的属性; this.$set : this.$...

  • 使用vue.set() (this.$set)更新视图

    更新某些List数据时 视图(页面)不会实时更新 ,需要使用 this.$set更新 第一种:this.$set(...

  • vue this.$set

    对于已经创建的实例,Vue 不允许动态添加根级别的响应式属性。但是,可以使用 Vue.set(object, pr...

  • this.$set() 用法

    参考文章: https://www.cnblogs.com/wangqi2019/p/11690208.htmlh...

  • vue.set/this.$set

    vue项目中,几个表格分开展示,但是展示的内容都一样(不展示的内容有区别),为了省事儿,就给封装了个子组件,但是在...

网友评论

      本文标题:this.$set 会跳出循环

      本文链接:https://www.haomeiwen.com/subject/dtztdktx.html