vite.config.js配置@

hykeda4年前Vue3180
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path' //需要引入

export default {
  plugins: [
    vue(),

  ],

    //增加别名

  resolve:{
    alias:{
      '@':path.resolve(__dirname,'./src')
    }
  }
};

如果在ts中提示 找不到模块 “path“ 或其相对应的类型声明

解决方法,下载插件 npm install @types/node --save-dev

标签: vitevue3path

相关文章

vue3项目,Element-plus ElMessage API 调用样式丢失问题

1、Element-plus使用了自动按需导入,vite.config.js配置如下:defineConfig({     plugins: [...

vuex存储和本地存储(localstorage、sessionstorage)的区别

1. sessionStorage    sessionStorage 方法针对一个 session 进行数据存储。当用户关闭浏览器窗口后,数据会被删除。   用法: ...

前端常用的UI组件库

Arco DesignTaro UISemi DesignAnt DesignElementView DesignVantLayui-vueFusion Design1. Arco Desi...

vue3中defineProps传值使用ref响应式失效详解

子组件接收父组件的传参。父组件:<template> <Son :data="data"/> </template> <s...

学习lodash

官网:https://www.lodashjs.com/ 链接:https://www.jianshu.com/p/d46abfa4ddc9 简介 L...

vite+vue 插件/组件集合

自动引入插件:https://github.com/antfu/unplugin-auto-importvue的按需组件自动导入:https://github.com/antfu/unplugin-v...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。