新聞中心
本篇文章給大家分享的是有關(guān)vue中怎么利用resource發(fā)送請求,小編覺得挺實用的,因此分享給大家學(xué)習,希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。
vue resource發(fā)送請求,代碼如下所示;
vue-resource
知識點擴展;vue-resource請求的幾種方式
安裝import VueResource from 'vue-resource'
Vue.use(VueResource) get //獲取 getdesignatepl({commit,rootState}){ // console.log("ppppp") let designate_list = `schedule-plan-configuration`; Vue.http.get(api.get(designate_list),{headers:rootState.headers}).then(function(response){ let pup=response.data.data; // console.log(response) },function(response){ // console.log("pl") var tipsObj = { title : "數(shù)據(jù)錯誤", flag: true, type: 4, btnGroup:['ook'] } commit('popup',tipsObj,{root:true}); }) } post//新增 setAdd({commit,rootState,state,dispatch,context},mss){ Vue.http.post(api.save('schedule-plan-configuration'),mss,{headers:rootState.headers}).then(function(response){ dispatch("getdesignatepl") commit('popup',titleObj,{root:true}); },function(response){ if(response.status == 422){ commit('popup',tipsObj,{root:true}); } }) }, //刪除 BrDelete(context,obj){ let br_delete_put_data = `schedule-plan-configuration/${obj.id}` Vue.http.delete(api.get(br_delete_put_data),{headers:context.rootState.headers}).then(function(response){ context.dispatch("getdesignatepl"); },function(response){ // console.log(response); if(response.status == 401 || response.status == 500){ var tipsObj = { status: response.status, flag: true, type: 4, btnGroup:['ook'] } context.commit('popup',tipsObj,{root:true}); return; } }) }, // 跟新 getEntrySales({commit,rootState,dispatch,context},obj){ // console.log(obj.id) Vue.http.put(api.update(`schedule-plan-configuration/${obj.id}`),obj, {headers:rootState.headers}).then(function(response){ dispatch("getdesignatepl"); },function(response){ }) },
以上就是vue中怎么利用resource發(fā)送請求,小編相信有部分知識點可能是我們?nèi)粘9ぷ鲿姷交蛴玫降摹OM隳芡ㄟ^這篇文章學(xué)到更多知識。更多詳情敬請關(guān)注創(chuàng)新互聯(lián)成都網(wǎng)站設(shè)計公司行業(yè)資訊頻道。
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
網(wǎng)頁題目:vue中怎么利用resource發(fā)送請求-創(chuàng)新互聯(lián)
網(wǎng)頁URL:http://fisionsoft.com.cn/article/dshscg.html