JS object type to encode encoding splicing url

Write an object type parameter to href, and send a GET request to read the download list from the background. You need to convert the object to json first, and then use the native js api encodeURIComponent to convert to encode

compEncodeUrl:function(prefix = 'https://blog.csdn.net?query=',params = {
    
    }){
    
    
    let json = JSON.stringify(params)
    return `${
      
      prefix + encodeURIComponent(json)}`
  }

Guess you like

Origin blog.csdn.net/qq_41109610/article/details/114558456