vue項目報錯——$axios is no defined

vue項目報錯——$axios is no defined

1、在main.js中加入如下代碼:

import axios from 'axios'
Vue.prototype.$axios = axios

2、在app.vue中改成:

this.$axios
      .get('http://localhost:8084/demo/user/userList')
      .then(response => (this.items = response))
      .catch(function (errer) {
        console.log(errer)
      })
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章