如何生成用户代码片段(快捷生成代码)
点击用户代码片段
新建全局代码片段,然后起个名字
{"vue": {"prefix": "vue","body": ["<template>"," <div class=\"container\">"," "," </div>","</template>","","<script setup lang='ts'>","","</script>","","<style lang=\"less\" scoped>","","</style>"],"description": ""},
}
这个复制进去就可以直接用
配置@路径(路径别名)
vite.config.ts
1.引入path
2.配置
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from "path";// https://vitejs.dev/config/
export default defineConfig({plugins: [vue()],resolve:{alias:{"@":path.resolve(__dirname , "./src"),}}})
tsconfig.json
1.配置path
{"compilerOptions": {"target": "ES2020","useDefineForClassFields": true,"module": "ESNext","lib": ["ES2020", "DOM", "DOM.Iterable"],"skipLibCheck": true,/* Bundler mode */"moduleResolution": "bundler","allowImportingTsExtensions": true,"resolveJsonModule": true,"isolatedModules": true,"noEmit": true,"jsx": "preserve",/* Linting */"strict": true,"noUnusedLocals": true,"noUnusedParameters": true,"noFallthroughCasesInSwitch": true,"paths":{"@/*" :["./src/*"]}},"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"],"references": [{ "path": "./tsconfig.node.json" }]
}