久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

Vue-resource安裝過程及使用方法解析

瀏覽:114日期:2023-01-01 14:59:52

1、安裝

npm install vue-resource --save

2、在main.js中添加

import VueResource from ’vue-resource’//全局注冊Vue.use(VueResource)

3、vue-resource發(fā)送請求

a)對象參數(shù),post請求

this.$http.post(’http://127.0.0.1:8081/getUserByParam’, { userName: this.username, sex:this.sex }).then((response) => { })

b)get請求

this.$http.get(’http://127.0.0.1:8081/getUserById’,{ params:{id:2}//注意,get請求一定要加params,post請求不需要 }).then((response) =>{ this.list=response.body console.log(this.list) });

c) json參數(shù)post請求,和對象參數(shù)post請求一樣

this.$http.post(’http://127.0.0.1:8081/getUserByJson’, { 'id':'11', 'userName':'jie' }//注意,get請求一定要加params,post請求不需要 ).then((response) =>{ this.list=response.body console.log(this.list) })

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標簽: Vue
相關文章:
主站蜘蛛池模板: 牟定县| 米泉市| 洛宁县| 紫金县| 邵武市| 汉源县| 岚皋县| 湘阴县| 城市| 财经| 上栗县| 隆德县| 祁门县| 西丰县| 巴林右旗| 红桥区| 遵义县| 萝北县| 西畴县| 沛县| 安宁市| 永定县| 游戏| 沂水县| 姚安县| 阳谷县| 柳州市| 科尔| 河曲县| 河东区| 赫章县| 当阳市| 廉江市| 凌云县| 建湖县| 文安县| 阜康市| 丰顺县| 崇明县| 泰州市| 西安市|