Gods; help solve it.
Gods; help solve it.
take it apart and write.
form submission is wx.request
upload picture is wx.uploadFile
you need to write a general image upload interface, and the url of the picture is returned by the background of uploading the image. This general interface can be used in any form that needs to submit a picture.
when you add a picture, call the image upload API to get the url, of the picture and store it in the form data. It would be nice to submit the form in the same way as the normal form.
export function uploadFiles(filePath,token){ //
return new Promise((resolve, reject) => {
wx.uploadFile({
url:`${URL_PREV}upload`,
filePath:filePath,
name: 'file',
header:{
'content-type':'multipart/form-data',
'x-token':token
},
success: function(res){
let data = JSON.parse(res.data);
if (data.code==200) {
resolve(data.link);
}else {
reject(data.message);
}
}
})
}).catch(function(e){
wx.showToast({
title: e,
icon: 'none',
duration: 1500
})
});
};
adding an image is an interface. Get the url, of the picture and submit it with form.
upload by uploadFile and then return the file name and save it. The request submission form is submitted together in data {}
https://developers.weixin.qq.
to read the document! Look at formData
Previous: Static files in static cannot be accessed after electron-vue is packaged.
Next: Vue-cli I websocket encapsulated, how do I listen in the component to get the data
ask the above line (introduction catalog work information, which is a simple tag above and content below) if I use vue.js, I think of implementing it in router, but is there any way to change url, without changing url? Because this part of the functi...
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title< title> < head> <body> <form enctype="multipart form-data" method="post" id=&qu...
when I cut a picture, I always use a ruler to measure the distance between the top div of a line of text or the px of another line of text, but each line of text has its own inner margin. There must be some deviation in measuring with a ruler. How to sol...