Loading

vue3单页抽取api

编写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
    }
}
posted @ 2023-02-10 10:59  sstu  阅读(22)  评论(0编辑  收藏  举报