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