var m_params = getOptions(); for(let i=0;i< self.files.length;i++){ param.append('file', self.files[i]);//通过append向form对象添加数据 } var m_params = getOptions(); param.append("name", values.name); param.append("master", values.master); param.append("type", values.type); param.append("startTime", values.accountEffect); param.append("stopTime", values.accountFailure); param.append("phone", values.phone); param.append("userId", m_params.userId); param.append("channel_id", m_params.channelId); var m_url = ""; if(!self.id){ m_url = "/channel/addChannel"; self.loadingFailure = false; }else{ m_url = "/channel/editChannel"; // m_params.id = self.id; param.append("id", self.id) } param.forEach((value, key) => { console.log(`key ${key}: value ${value}`); }) axios({ url: window._CONFIG['domianURLXunHu'] + m_url, data: param, method:'post' , headers: { 'Content-Type': 'multipart/form-data', // 文件上传 }, });
form表单的参数比较特殊,正常的console.log(formData)是什么都打印不出来的
用如下的方式打印
param.forEach((value, key) => {
console.log(`key ${key}: value ${value}`);
})