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.不是很好,以后在改进