修改 vuex $store.state 里取出的數據不響應


一定要先拷貝

 

let { showLabel, actualValue } = this.record;
      let show = this.rowData[showLabel];
      let actual = this.rowData[actualValue];
      const { formGroup } = this.$store.state.right;
      const { dispatch } = this.$store;
      let group = _.cloneDeep(formGroup) // 這一步必須, 如果直接 formGroup.map( ... ) 數據響應不到
      const newFormGroup = group.map(item => {
        if (item.componentx === "modal") {
          item = {
            ...item,
            uniqueKey:createUuid()
          }
          return (item = {
            ...item,
            initValue: show,
            actualValue: actual
          });
        } else {
          return item;
        }
      });
      dispatch("right/updateFormGroup", newFormGroup);
      this.visible = false;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM