element ui axios使用formdata提交数据

 axios({
                        //formdata提交
                        headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
                        transformRequest: [function (data) { let ret = ''; for (let it in data) { ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'; } return ret; }],
                        method: 'post',
                        url: 'handler/test',
                        data: {
                            id: myVue.form.id
                        }
                    }).then((res) => {
                        if (res.data.status == 0) {
                            myVue.$message({ message: res.data.msg });
                        } else {
                            myVue.$message.error(res.data.msg);
                        }
                    });

 

posted @ 2019-12-02 16:38  吉姆杨  阅读(1300)  评论(0编辑  收藏  举报