Vue3 前端传递字典格式会变味

axios
    .post('http://127.0.0.1:5000/'+modalAction.value+'_data',modalData.value,{headers:{'Content-Type':'application/json;charset=UTF-8'}})
    .then(response => (handelResponse(response['data'])))
    .catch(function (error) { // 请求失败处理
        console.log(error);
    });

注意:data 不要加 qs.stringify({id:id}) 不然会变格式(测了一晚上才发现 ,headers 应该需要设置一下

后台接收

dataGet = request.get_data()
dataJson = json.loads(dataGet)
data = {'id':dataJson['key']}

即可

posted @ 2023-04-04 22:23  cccht  阅读(71)  评论(0)    收藏  举报