Home > Article > Web Front-end > What is the difference between get and post requests in vue
Difference: 1. In the GET request, the parameters follow the URL, that is, the parameters are placed in the header; in the POST request, the parameters are placed in the body and do not follow the URL. 2. The parameters that can be passed in the get request are smaller, and the parameters that can be passed in the post request are larger.
The operating environment of this tutorial: windows7 system, vue2.9.6 version, DELL G3 computer.
The difference between get and post requests in vue
1. Get request
In GET The parameters in the request follow the URL, that is, the parameters are placed in the header. The parameters that can be passed are small. Use params.
this.$http.get(' URL ').then(result=>{ if(result.status===0){ // 成功了 this.list=result.message; // 这里是假设被请求的数据表中的列表名称为message }else{ // 失败了 ,弹出窗体警告 alert("数据请求失败"); } })
2. Post request
In the POST request, the parameters are placed in the body and do not follow the URL. Using data, the parameters passed are larger.
this.$http.post('URL',{id:this.id},{emulateJSON:true})..then(result=>{ if(result.body.status===0){ // 成功了 }else{ // 失败了 alert("获取数据失败!"); ] })
[Related recommendations: "vue.js tutorial"]
The above is the detailed content of What is the difference between get and post requests in vue. For more information, please follow other related articles on the PHP Chinese website!