How to use set () to add attributes to determine how to optimize to the simplest?

use the set () method to store the status of the payment, and then assign values to the button and title according to the status

data() {
    return {
      val: "",
      paymentState: "",
      goBackBtn: "",
      anewPayBtn: "",
      paymentTitle: {
        payAchieve: "",
        payCancel: "",
        payFailure: "",
      },
    };
  },

methods:{
    operate() {
          const _this = this;
          success() {
          // 
          _this.$set(_this.payVal, "seate", "payAchieve");

          if (_this.payVal.seate) {
            _this.val = _this.paymentTitle.payAchieve;
            _this.getPayState();
          }
        },
        cancel() {
          // 
          _this.$set(_this.payVal, "seate", "payCancel");

          if (_this.payVal.seate) {
            _this.paymentState = _this.anewPayBtn;
            _this.val = _this.paymentTitle.payCancel;
          }
        },
    },
    
    getPayState() {
        // 
        this.$set(this.payVal, "seate", "payFailure");

        if (this.payVal.seate) {
          this.paymentState = this.paymentTitle.payFailure;
          this.val = this.paymentTitle.payCancel;
        }
    }
}
May.26,2022

use calculation properties?

Menu