Js mock 简易配置

1,定义mockserver.js文件

import Mock from "mockjs";
import signData from "./mock/sign.mock";
export default function mockServer() {
  console.log("mock server start successfully!!");
  Mock.mock("/api/login", signData);
  Mock.mock("/api/register", signData);
}

2,在应用入口文件 main.js中

import { createApp } from "vue";
import App from "./App.vue";
import "./scss/global/index.scss";
// import Test from "./tool/test";
import router from "./router/index.js";
import ElementPlus from "element-plus";
import "element-plus/dist/index.css";
/** mockserver */
import mockServer from "../server";
mockServer();
const app = createApp(App);
app.use(ElementPlus);
app.use(router);
// app.use(Test);
app.mount("#app");

导入

你可能感兴趣的:(JavaScript工具,javascript,前端,vue.js)