1.初始化前端项目
2.配置代理
nuxt.config.ts
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: { enabled: true },
modules: ["@element-plus/nuxt", "@pinia/nuxt", "@nuxt/ui"],
css: ["element-plus/dist/index.css"],
vite: {
server: {
proxy: {
// 代理配置
"/api": {
//将接口开头路径为/api的接口 代理到target
target: "http://localhost:8080",
changeOrigin: true,
},
},
},
},
plugins: ["~/plugins/element-plus.ts", "~/plugins/axios.ts"],
});