Vue使用Post進(jìn)行表單提交
使用Post進(jìn)行表單提交
下面就是使用Vue提交表單的方法

submitForm(event) {
event.preventDefault();
let formData = new FormData();
formData.append('id', this.param.id);
formData.append('categoryName', this.param.namee);
formData.append('description', this.param.descrip);
var url ="";
if(this.isSave){
url = "http://localhost:8080/bookStore/category.do?flag=add"
}else{
url = "http://localhost:8080/bookStore/category.do?flag=update&id="+this.param.id
}
this.$http.post(url, formData).then(function (res) {
if (res.status === 200) {
this.isShowModal=false;
var title = this.isSave?"添加成功!":"修改成功!";
swal({title:title,text:"",type:"success"});
this.queryData();
this.clearData();
}
})
}vue中使用Post問題
get的使用
this.$axios.get("/api/Main/InputValue",{
? ? ?params:{ //傳參
? ? ? ? ?json:"123"
? ? ?}
})
.then(function(res){
? ? ?//console.log(res) ? ? ? ? ?
})
.catch(function(err){
? ? ? console.log("請求失敗233");
});post的使用
this.$axios.post("/api/Main/posttest",{json:"123"})//傳參
.then(function(res){
? ? ? console.log(res) ? ? ? ? ?
})
.catch(function(err){
? ? ? console.log("請求失敗233");
});post和get傳參數(shù)的方式是不一樣的,寫post的時(shí)候如果在params里面?zhèn)鲄?shù),后臺(tái)是收不到的~~~~
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
Vue實(shí)例初始化為渲染函數(shù)設(shè)置檢查源碼剖析
這篇文章主要為大家介紹了Vue實(shí)例初始化為渲染函數(shù)設(shè)置檢查源碼剖析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-08-08
一篇看懂vuejs的狀態(tài)管理神器 vuex狀態(tài)管理模式
一篇看懂vuejs的狀態(tài)管理神器,Vuex一個(gè)專為Vue.js應(yīng)用程序開發(fā)的狀態(tài)管理模式,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-04-04
Vue中使用event的坑及解決event is not defined
這篇文章主要介紹了Vue中使用event的坑及解決event is not defined,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-03-03
Vue實(shí)例的對象參數(shù)options的幾個(gè)常用選項(xiàng)詳解
今天小編就為大家分享一篇Vue實(shí)例的對象參數(shù)options的幾個(gè)常用選項(xiàng)詳解,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-11-11
Vue 動(dòng)態(tài)生成數(shù)據(jù)字段的實(shí)例
這篇文章主要介紹了Vue 動(dòng)態(tài)生成數(shù)據(jù)字段的實(shí)例,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-04-04
vue-admin-element項(xiàng)目突然就起不來了的解決
這篇文章主要介紹了vue-admin-element項(xiàng)目突然就起不來了的解決方案,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-10-10
vue在響應(yīng)頭response中獲取自定義headers操作
這篇文章主要介紹了vue在響應(yīng)頭response中獲取自定義headers操作,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-07-07

