let fileFormData = new FormData();
fileFormData.append('File',this.initFile);
let requestConfig = {headers: {"Content-Type": "multipart/form-data"}};
withCredentials:true
表示跨域请求时是否须要使用凭证. 默认为false//点击发送事件
preserveCompanyName() {
import axios from 'axios' //先下载axios (npm i axios -D)!!!(不在这里写,而后在export default 外引入)
let fileFormData = new FormData();
fileFormData.append('File',this.initFile);
let requestConfig = {
headers: {
"Content-Type": "multipart/form-data"
}
};
const instance = axios.create({
withCredentials: true
})
instance.post('http://192.168.1.48:8000/basicTable/upload_file',fileFormData,requestConfig ).then(res=>{
this.$message.success('上传成功!')
})
this.dialogVisible1 = false;
}
复制代码
至此 完结!best regards!vue