utils.js中
async getmaterialList() {
try {
const res = await axios.post('接口')
return res.data.data
} catch (error) {
console.log(error)
}
},xxx.vue文件中引用
this.$utils.getmaterialList().then((res) => {
console.log(res);//res为公共接口返回的数据;返回的数据为utils.js中return的数据
});版权声明:本文为apple_49915942原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。