Garbled characters will appear in Chinese on the vue jump page with parameters

As shown in the picture, the format of the parameters I carry is as follows:
insert image description here
Then you can see that the upper URL is correct Chinese, but the lower URL becomes garbled characters after parsing.
insert image description here

Solution:
use decodeURIComponentthe function, the code is used as follows:
insert image description here
paste the code:

    get_url_query() {
    
    
      var str = decodeURIComponent(window.location.href)
      var num = str.indexOf('?')
      str = str.substr(num + 1)
      var arr = str.split('&')
      for (var i = 0; i < arr.length; i++) {
    
    
        num = arr[i].indexOf('=')
        if (num > 0) {
    
    
          this.query[arr[i].substring(0, num)] = arr[i].substr(num + 1)
        }
      }
      if (this.query.vin) {
    
    
        this.vin = this.query.vin
        console.log(this.vin)
        this.get_vehicle_info()
      }
    },

Then you can see that the conversion is successful!
insert image description here

Guess you like

Origin blog.csdn.net/changyana/article/details/129698158