1.命令安装axios和vue-axios
npm install axios --save
npm install vue-axios --save
2.package.json查看版本
3.在main.js中引用
import axios from 'axios';
import VueAxios from 'vue-axios';
Vue.use(VueAxios,axios)
4.如何使用
(初始化方法)
将下列代码放在Home.vue中:
export default {
name: 'HomeView',
下边即可
methods:{getList(){this.axios.get('http://localhost:3312/user/getList',{params:{page:this.query.page,size:this.query.size,name:this.query.name,phone:this.query.phone,city:this.query.city}}).then((resp)=>{console.log(resp);this.tableDate =resp.data,content.list;this.total=resp.data.content.total;})},}