首页 > 代码库 > vue写请求接口--请求参数的变量要在return里面声明
vue写请求接口--请求参数的变量要在return里面声明
//谨记return里面是返回所有声明的变量的名字,数组以及对象等等 export default { data () { return { //所有的变量都是写在data 的return里面的,主要错误点在于请求参数的变量要在这里声明; imgGroup: { user: require(‘../static/images/icon/user-ava.png‘), payment: require(‘../static/images/icon/wait-payment.png‘), delivery: require(‘../static/images/icon/wait-delivery.png‘), receive: require(‘../static/images/icon/wait-receive.png‘), completed: require(‘../static/images/icon/order-completed.png‘), detail: require(‘../static/images/icon/bonus-detail.png‘), card: require(‘../static/images/icon/bonus-card.png‘), manage: require(‘../static/images/icon/address-manage.png‘), maket: require(‘../static/images/icon/after-maket.png‘), jfs: require(‘../static/images/icon/about-jfs.png‘) }, requestUrl: { scoreTotal: ‘/scoreTotal‘ }, requestParam: { scoreTotal: {//这里是要传递的参数 userId: "2768", token: "b15dJIVKbfX1vfODv78erjDJwZre1QVhbzYzUYj2ep7uM07vFE9BCA==", ppInfo: "AxMDA3NDkw%Mjc2ODE4Mz", browser: "Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d Safari/600.1.4", clientType: 3, version: "1.0.0001.0613" } }, credits: "",//当前积分,这里是页面所需要显示声明的变量 deductCash: "",//可抵扣金额 } }, created () { var vm = this; vm.creditRequest(); }, methods: { //获取总积分 creditRequest(){ var vm = this; vm.$http.post(vm.requestUrl.scoreTotal, vm.requestParam.scoreTotal, { headers: { "X-Requested-With": "XMLHttpRequest" }, timeout: 5000, emulateJSON: true }).then(function (res) { var data = http://www.mamicode.com/res.data;>
vue写请求接口--请求参数的变量要在return里面声明
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。