The Perplexity of submitting data with axios and formData

I need to implement an image upload function and submit it to the background with not only pictures but also other parameters.
now I have encountered a very troublesome problem. After reading a lot of materials, it is said that this formData is a method of prototype encapsulation. The added values are private attributes that cannot be accessed normally and need to be accessed through the formData.get () method
, but I must be able to access them through the syntax of formData.cityNo, because when I request the interface, the parameters other than the image need to be encrypted, that is to say, when I process the parameters, I need to judge that if it is an image file, do not deal with
the key is It is not possible to access parameters directly now. Is there any way to solve this problem?
let formData = new FormData (this.$refs.form);

  formData.append("file1",this.file1)
  formData.append("file2",this.file2)
  accountManage.changeBankCard(formData).then(res => {
    console.log(res)
  })

this params is the formData above. When I iterated through for in, I didn"t actually traverse the parameters, so my judgment didn"t work
for (var key in params) {

.
    if(key != "file1" && key != "file2" ) {
      a[a.length] = key;
    }

}

Mar.23,2021

do you just want to get the attribute and encrypt it?

try for key of formData.keys () and then formData.set (key, value)?

https://developer.mozilla.org.


json can also transfer files with parameters.

{
name:'',
birthday:'',
photo: BAS64
}

Menu