main.js:
import axios from 'axios' //npm install axios -S
import VueAxios from "vue-axios" //npm install axios vue-axios --save
Vue.use(VueAxios,axios)
命令:
npm install axios -S
npm install axios vue-axios --save
函数内使用:
如:
this.axios //这里要加this .get( "https://www.fastmock.site/mock/820259754c7de3b262ea7aa67d2f663a/manage/product2", { params: { name: this.screenKey.name, region: this.screenKey.region, keyword: this.screenKey.keyword, barcode: this.screenKey.barcode, classify: this.screenKey.classify, allType: this.screenKey.allType, allSellType: this.screenKey.allSellType, }, } ) .then((ret) => { console.log(ret) this.productsData = ret.data.data;//这里注意有几个data }) .catch(function (ret) { console.log("error"); console.log(ret.data); })