vite.config.js配置@

hykeda4年前Vue3502
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中defineProps传值使用ref响应式失效详解

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

使用vite打包vue项目生成dist文件夹,部署至nginx除了index.html,其他路径都提示404错误的解决

使用vite打包vue项目生成dist文件夹,部署至nginx除了index.html,其他路径都提示404错误的解决

用vue打包生成dist文件夹,然后在本地nginx部署vue项目时只能访问默认页面,刷新和跳转页面都会出问题。原因:只访问了dist文件下的 index.html、index.htm页面,...

vite配置代理proxy实现跨域问题

最近在开发vite+vue项目时,调用接口获取服务器数据时提示接口有跨域问题,解决办法是配置代理:export default defineConfig({  //配置代理  se...

vue中的h函数使用

一、参数设置h函数接收三个参数。第一个参数:,可以为一个html标签,一个组件,一个异步组件,或者是一个函数式组件。第二个参数:{ Object } Props,与attributes和props,以...

前端常用的UI组件库

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

vite+vue 插件/组件集合

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

发表评论    

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