Closed Allennnn2022 closed 3 months ago
mock仿照users写的:
{ url: "users/TaskShow", method: ["GET"], body: { code: "00000", data: [ { taskname: "Task1", taskstate: "running" }, { taskname: "Task2", taskstate: "starting" }, ], msg: "一切ok", }, },
请求函数:
import request from "@/utils/request"; //import SERVER_URL from "@/App.vue"; const USER_BASE_URL = "/api/v1/users"; export function gettasklist(query: object) { return request<any, Tasklist[]>({ //url: `${SERVER_URL}/user`, url: `${USER_BASE_URL}/TaskShow`, method: "get", params: query, }); } export interface Tasklist { // 任务名称 taskname?: string; // 任务状态 taskstate?: string; }
相应包如下:{"code":"B0001","data":null,"msg":"Request method 'GET' is not supported"}
求解惑是不是哪里写的有问题
url: `${SERVER_URL}/user/TaskShow
那个注释掉了,下面一行才是实际的url
把这个打开,然后自己在 Devtools 里看调试信息吧!
然后看看下面这个:
感谢,原来是没用本地mock
mock仿照users写的:
请求函数:
相应包如下:{"code":"B0001","data":null,"msg":"Request method 'GET' is not supported"}