天天看点

避免多层的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')
+
                  });
+
                });
+
              }
+
            }      

继续阅读