一 . vite.config.ts 配置
/*
* @Author: mfxhb
* @Date: 2022-11-07 09:46:31
* @LastEditTime: 2022-11-07 11:22:08
* @Description:
*/
// https://vitejs.dev/config/
export default defineConfig({
css: {
preprocessorOptions: {
less: {
math: "always", // 括号内才使用数学计算
globalVars: {
// 全局变量
mainColor: "red",
},
},
},
},
});
二: 安装less
pnpm i less -save
三: 接着正常使用
import { createApp } from "vue";
import TDesign from "tdesign-vue-next";
import "tdesign-vue-next/es/style/index.css";
import "normalize.css"; // 浏览器兼容
import "./styles/index.less";// 项目样式
import App from "./App.vue";
createApp(App).use(TDesign).mount("#app");