Vue基础知识之axios和vue-resource

1.axios官方中文说明

https://www.kancloud.cn/yunye/axios/234845

2.axios官方文档

https://github.com/axios/axios

3.axios和vue-resource

https://www.cnblogs.com/Juphy/p/7073027.html

4.引入全局

Vue.prototype.$http = axios可以全局使用,例如:
import Vue from 'vue'
import router from './router/router.js'
import store from './store/store.js'
import axios from 'axios'
Vue.prototype.$http = axios

import VueLazyload from 'vue-lazyload'
Vue.use(VueLazyload)

const app = new Vue({
  router,
  store
}).$mount('#app')

export default app
methods: {
      getDataCart () {
        console.log(this.$route.params.id)
        this.$http({
          url: '/api/goods/detail',
          method: 'GET',
          params: {
            brand_id: this.$route.params.id
          }
        })
          .then((res) => {
            let data = res.data
            console.log(data)
            if (data.code === 200) {
              // 合并字段 cart_num
              this.detailData = Object.assign(this.detailData, data.data)
            } else {
              console.log(data.msg)
            }
          })
      },

 5.不是很好,以后在改进

转载于:https://www.cnblogs.com/beimingbingpo/p/7929797.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值