天天看點

避免多層的if嵌套

if (!this.hasConfigured) {
+
            if (this.isKeySubmit) {
+
              if (this.selfTransferDevice) {
+
                let promise1 = this.putSelfTransDeviceConfig();
+
                let promise2 = this.setHPCEvent();
+
                Promise.all([promise1, promise2]).then(() => {
+
                  this.$message({
+
                    type: 'success',
+
                    message: i18n.t('hcp_system_save_success')
+
                  });
+
                });
+
              } else {
+
                this.setHPCEvent().then(()=> {
+
                  this.$message({
+
                    type: 'success',
+
                    message: i18n.t('hcp_system_save_success')
+
                  });
+
                });
+
              }
+
            }      

繼續閱讀