编写api
import axios from '~/util/axios'
const findByPage = (data) => {
return axios.post("/emo/page", data)
}
const login = (data) => {
return http.post("/user/login", data);
};
export default {
login, findByPage
}
在页面中使用
import userApi from "../../api/emo.js";
指定方法
const load = async () => {
const res = await userApi.findByPage({
name: name.value,
address: address.value,
currentPage: pageNum.value,
pageSize: pageSize.value
});
if (res.code === 200) {
state.tableData = res.page.list
total.value = res.page.totalCount
}
}