axios.post
@ Zhang zhiyang · Monday, Jan 1, 0001 · 1 minute read · Update at Monday, Jan 1, 0001

axios的post传值问题

axios({
    url:"http://127.0.0.1:8000/index/saveuser",
    method:"post",
    data: this.form,
    transformRequest: [function (data) {
        // Do whatever you want to transform the data
        let ret = ''
        for (let it in data) {
        // 如果要发送中文 编码 
        ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
        }
        return ret
    }],
    headers: {'Content-Type':'application/x-www-form-urlencoded' }
}).then(res=>{
    if(res.data.status){
        ElMessage.success({
            message: '恭喜你,' + res.data.message,
            type: 'success',
        })
        this.form = {sex:'男'}
        this.show = false
        this.getUserByPage(this.currentPage)
        this.getTotal()
    }else{
        ElMessage.error(res.data.message)
        return false
    }
})
Zhang zhiyang's blog
不过是些许风霜罢了
c cyber http linux math mysql php python 前端

© 2016 - 2022 Zhangzhiyang的博客

Powered by Hugo with theme Dream.

我听别人说这世界上有一种鸟是没有脚的,它只能够一直的飞呀飞呀,飞累了就在风里面睡觉,这种鸟一辈子只能下地一次,那一次就是它死亡的时候。

日程

Zhangzhiyang的 ❤️ 博客

其他

如果你喜欢我的开源项目或者它们可以给你带来帮助,可以赏一杯咖啡 ☕ 给我。~

If you like my open source projects or they can help you. You can buy me a coffee ☕.~

PayPal

https://paypal.me/g1eny0ung

Patreon

Become a Patron!

微信赞赏码

wechat

最好附加一下信息或者留言,方便我可以将捐助记录 📝 下来,十分感谢 🙏。

It is better to attach some information or leave a message so that I can record the donation 📝, thank you very much 🙏.