vue 中使用axios

1.package.json 中引入axios

  "dependencies": {
    "axios": "^0.15.3",
    "element-ui": "1.0.9",
    "lodash.debounce": "^4.0.8",
    "vue": "2.1.6",
    "vue-router": "^2.1.1",
    "vuex": "^2.1.2"
  },
 2.vue中引入axios
Vue.prototype.axios = axios;
3. axios 方法中绑定 vue的this
 }).then(function (response) {
              console.log(response);
            this.$router.push({ path: 'companyIndex' })
            }.bind(this))
            .catch(function(err){
              console.log(err)
            })
         

猜你喜欢

转载自feiteyizu.iteye.com/blog/2386673