使用react-vite-antd,修改antd主题,报错 [vite] Internal server error: Inline JavaScript is not enabled. Is it set in your options? It is hacky way to make this function will be compiled preferentially by less
一般报错

在官方文档中,没有关于vite中如何使用自定义主题的相关配置,经过查阅
1.安装less yarn add less (已经安装了就不必再安装)
2.首先将App.css改成App.less,记得将app.ts(或者.tsx/.js)中的引入更改为 import "./App.less";
3.在App.less中,将原先引入的@import 'antd/dist/antd.css' 更改为 @import 'antd/dist/antd.less';
4.在vite.config.ts(.js)中进行修改
vite 2X
export default defineConfig({
css:{
preprocessorOptions:{
less:{
javascriptEnabled: true, //注意,这一句是在less对象中,写在外边不起作用
modifyVars:{ //在这里进行主题的修改,参考官方配置属性
'@primary-color': '#1DA57A',
},
}
}
},
})
vite 1X
export default{
cssPreprocessOptions:{
less:{
javascriptEnabled:true
}
}
}
然后刷新或者重启就好了
使用react-vite-antd,修改antd主题,报错 [vite] Internal server error: Inline JavaScript is not enabled. Is it set in your options? It is hacky way to make this function will be compiled preferentially by less的更多相关文章
- Ajax 报错 500 (Internal Server Error)
==========error======={"readyState":4,"responseText":"<html><head& ...
- CI当开启URL重写的时候,报错500 Internal Server Error
Internal Server Error The server encountered an internal error or misconfiguration and was unable to ...
- ivew定制主题 less ^3.0 时报错 .bezierEasingMixin(); Inline JavaScript is not enabled. Is it set in your options?
按照 ivew 提供的方法定制主题,创建一个 less 文件,在其中覆盖变量,再在 main.js 中引入.戳这里 出现报错: 问题貌似是在于 less 版本...两种解决方法: 1.打开项目pack ...
- kolla部署openstack allinone,报错APIError: 500 Server Error: Internal Server Error (\"oci runtime error: container_linux.go:235: starting container process caused \"container init exited prematurely
使用 kolla-ansible 部署 opnenstack:stein 执行 kolla-ansible -i ./all-in-one deploy 开始自动化部署 在部署过程中报错,报错信息如下 ...
- react、less、antd-mobile 报错Inline JavaScript is not enabled. Is it set in your options?
增加less-loader里面的配置.如图或者降级less到2.x版本
- Mysql 编译报错 g++: internal compiler error: Killed (program cc1plus) 解决办法
g++: internal compiler error: Killed (program cc1plus) 解决办法 g++: internal compiler error: Killed (pr ...
- 在React组件unmounted之后setState的报错处理
最近在做项目的时候遇到一个问题,在 react 组件 unmounted 之后 setState 会报错.我们先来看个例子, 重现一下问题: class Welcome extends Compone ...
- Mysql导入大文件报错(MySQL server has gone away(error 2006))
前言 我们在导入mysql数据时候,mysql客户端突然报错:MySQL server has gone away(error 2006) 类似这种情况,处理思路为:调节mysql允许导入包的大小即可 ...
- vue解决启动报错cjs loader.js Error: Cannot find module '../config'问题
vue解决启动报错cjs loader.js Error: Cannot find module '../config'问题 今天下载了一个开源项目一直运行不了,折腾了半天才找到问题所在,config ...
- Pytorch报错:cuda runtime error (59) : device-side assert triggered at /pytorch/aten/src/THC/generic/THCTensorMath.cu:26
Pytorch报错:cuda runtime error (59) : device-side assert triggered at /pytorch/aten/src/THC/generic/TH ...
随机推荐
- Linux下的zip和tar压缩解压缩命令详解
一.zip压缩工具 zip的压缩包在windows和linux中都比较常用,它可以压缩目录和文件,压缩时录时,需要指定目录下的文件.zip后面先跟目标文件名,即压缩后得自定义压缩包名,然后跟要压缩的文 ...
- ASP.NET Core连接字符串中的特殊字符如何处理?多实例如何连接?
ASP.NET Core连接字符串中的特殊字符,如数据库密码,有时会有特殊字符,如password&1234, 如何直接使用会报连接错误,只需用单引号阔起来即可,如下'password& ...
- 每日一抄 Go语言聊天服务器
server.go package main import ( "bufio" "fmt" "log" "net" ) ...
- 在 C# 中调用FastReport 设计窗口
因为引入FastReport中的控件时报错,在网上又搜不到相应的解决办法 所以在这里动态添加 首先在创建的项目中引入FastReport.dll //创建一个空的报表 Report report = ...
- 046_salesforce 中 Get URL
Suppose u have the whole URL as: < https://cs14.salesforce.com/apex/myVFpage?id=906F00000008w9wIA ...
- mybatis动态生成sql示例
- PWM脉宽调制
PWM(pulse width modulation) .由微处理器输出一系列占空比不同的矩形脉冲(单个周期相同),应用在测量,通信,功率控制与变换的许多领域.优点是从微处理器到被控系统的信号都是数字 ...
- Kubernetes--案例:使用Ingress发布tomcat
假设有这样一套环境: Kubernetes集群上的tomcat-deploy控制器生成了两个运行于Pod资源中的tomcat实例,tomcat-svc是将它们统一暴露于集群中的访问入口.现在需要通过I ...
- CCPC2021网络赛 1012 Remove
2021CCPC网络赛 1012 Remove 题意 给定 \(n, m\),然后再给 \(m\) 个素数,问对于所有 \(i \in [1,n]\),将 \(i\) 操作至 \(0\) 的最小操作数 ...
- Delphi中KeyPress、KeyUp、keydown事件区别
KeyPress: 当用户按下键盘上的字符键(字母,数字) 会触发该事件,功能键则不会(F1-F12,Ctrl,Alt,Shift) KeyUp: 当按下键盘上的按键松开时,会触发OnKeyUp事件( ...