目录
axios-get请求
created() { console.log('该组件要被加载成功了') this.$axios({ url: "http://127.0.0.1:8080/student/3", method: "get", headers: { // 'content-type': 'application/x-www-form-urlencoded' 'content-type': 'multipart/form-data' } }).then(response => { console.log(response) } ).catch(error => { console.log(456) console.log(error) } );
gin-get响应
r.get("/student/:id", func(c *gin.context) { id := c.param("id") var student student _ = c.shouldbind(&student) db.preload("teachers").preload("idcard").first(&student, "id=?", id) c.json(200, gin.h{ "msg": student, }) })
vue-post请求
this.$axios({ url: "http://127.0.0.1:8080/test", method: "post", headers: { 'content-type':'application/x-www-form-urlencoded', }, data: { "name": "jeff", "age": 18 } }).then(response => { console.log(response) } ).catch(error => { console.log(456) console.log(error) } );
gin-post响应
r.post("/test", func(c *gin.context) { user := c.postform("name") pwd := c.postform("age") fmt.println(user) fmt.println(pwd) fmt.println(c) c.json(200, gin.h{ "msg": "成功!", }) })
以上就是axios gin的get和post请求实现示例的详细内容,更多关于axios gin的get和post请求的资料请关注其它相关文章!