vuejs 前端 使用axios发送get、post请求 参数在query和body里面的各种情况


使用axios发送get请求,参数写在query里

async getOrgList() {
        let res = await this.$axios.get('/user/b/getOrgList', {
            params: {
                pageNo: 1,
                pageSize: 99,
                type: 6
            }
        })
        this.researchList = res.data.retData.list
    },

使用axios发送post请求,参数写在body里

async AddOrModifyIt() {
        await this.$axios.post('/project/b/project/updateProjectOrg', {
            leader: this.leader,
            oldOrgId: this.orgPrimaryId,
            planSubjectNum: this.planSubjectNum,
            sectionId: this.mainResearchValue.sectionId,
            userId: this.mainResearchValue.userId,
            userName: this.mainResearchValue.name
        })
    },

使用axios发送post请求,参数写在query里

async deleteRow(index, row) {
        await this.$axios.post(
            '/project/b/project/deleteProjectOrgById',
            {},
            {
                params: {
                    orgPrimaryId: this.orgPrimaryId
                }
            }
        )
    },

 注意:此时需要对参数做encodeURI转码;例如:encodeURI(AI 100);


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM