- 命令行里安裝 npm install --save vue-axios
- man.js 里
import axios from 'axios'
import VueAxios from 'vue-axios'
Vue.use(VueAxios,axios);
- 在組件中直接就可以使用
getNewsList(){
this.axios.get('api/getNewsList')
.then((response)=>
{
this.newsList=response.data.data;
})
.catch((response)=>{console.log(response); }
)},
- 更多方法點(diǎn)擊鏈接
https://blog.csdn.net/connie_0217/article/details/78703112