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的数据
});