国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

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

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

瀏覽:120日期: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
相關文章:
主站蜘蛛池模板: 湖北省| 体育| 东安县| 洛宁县| 吉安县| 敖汉旗| 平谷区| 克山县| 南漳县| 弥渡县| 图们市| 策勒县| 忻城县| 香港| 古丈县| 日喀则市| 益阳市| 武乡县| 华阴市| 汤原县| 西青区| 故城县| 萨嘎县| 汉中市| 正宁县| 嘉荫县| 武邑县| 合江县| 中西区| 青州市| 秦皇岛市| 陆丰市| 巧家县| 阿勒泰市| 吉隆县| 正阳县| 林口县| 六枝特区| 淳安县| 肃宁县| 九江市|