Vue3项目模板

vite+ts+vue3

项目依赖

"dependencies": {
    "@element-plus/icons-vue": "^2.1.0",
    "axios": "^1.3.4",
    "element-plus": "^2.2.32",
    "pinia": "^2.0.32",
    "pinia-plugin-persistedstate": "^3.1.0",
    "vue": "^3.2.45",
    "vue-router": "^4.1.6"
  }

main.ts

import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import ElementPlus from "element-plus";
import 'element-plus/dist/index.css'
import { router } from './router/index'
import { createPinia } from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import axios from 'axios';


const pinia = createPinia()
pinia.use(piniaPluginPersistedstate);
const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
app.use(ElementPlus, {
    locale: zhCn,
})
app.use(pinia)
app.use(router)

axios.interceptors.response.use(function (response) {
    if (response.status == 200) {
        if (response.data['code'] != 200) {
            // router.push({name: "login"})
        }
    }
    return response
})

app.mount('#app')