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

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

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

瀏覽:91日期: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發送請求

a)對象參數,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參數post請求,和對象參數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) })

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

標簽: Vue
相關文章:
主站蜘蛛池模板: 崇左市| 湖北省| 徐闻县| 永寿县| 奉贤区| 花垣县| 沾化县| 平顶山市| 余江县| 清丰县| 和平县| 那曲县| 镇远县| 长葛市| 元朗区| 务川| 和平县| 三都| 思茅市| 义乌市| 隆子县| 汤原县| 忻城县| 和田县| 东港市| 定结县| 吉木萨尔县| 农安县| 天门市| 共和县| 军事| 中西区| 芦山县| 贵南县| 天门市| 肇源县| 巴彦淖尔市| 汪清县| 清苑县| 伊宁县| 呼图壁县|