Vue http请求的写法

新手上路,请多包涵

image.png
当api文档如图,
在添加动/静态属性时 上课老师的写法是这样的

 const {data:res}= await this.$http.post(`categories/${this.cateId}/attributes`,{
                    attr_name:this.addForm.attr_name,
                    attr_sel:this.activeName
                })

能不能写成params格式

const { data: res } = await this.$http.post(`categories/${this.cateId}/attributes`,{params: {  attr_name:this.addForm.attr_name,
                    attr_sel:this.activeName }})

一直不懂这两种的区别
有些时候末尾的参数又能直接把data里的对象传进去
请问大神get post put请求体的区别

阅读 2.8k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题