How does the axios parameter convert illegal [] characters?

backend parameters need to convert the [] character before they can be accessed, and [convert to% 5B,] to% 5D

.

No pre-conversion

methods: {
    logicQueryData() {
        let str = JSON.stringify(this.taskArr);
        let paramsData = {
                table: this.value,
                andOr: this.queryOne,
                params: str
          };
       // 
       console.log("paramsData", paramsData);
    }
    this.$http
          .get(this.$api.logicalSearch + "logic", {
            params: paramsData
          })
          .then(res => {
              
          }
}

clipboard.png

clipboard.png


clipboard.png

Apr.22,2021

introduce qs to deal with the params, of get. Note that table first uses JSON.stringify to deal with


axiosparams %5B[

function encode(val) {
      return encodeURIComponent(val).
        replace(/%40/gi, '@').
        replace(/%3A/gi, ':').
        replace(/%24/g, '$').
        replace(/%2C/gi, ',').
        replace(/%20/g, '+').
        replace(/%5B/gi, '[').
        replace(/%5D/gi, ']');
    }
Menu