Inline JavaScript is not enabled. Is it set in your options?

本文介绍了解决使用ant-design-vue时遇到的less语法错误的具体步骤。针对不同版本的less-loader提供了两种不同的vue.config.js配置方法,确保正确加载JavaScript代码。

使用 ant-design-vue时,错误信息

 ERROR  Failed to compile with 1 error

 error  in ./node_modules/ant-design-vue/dist/antd.less

Syntax Error:

// https://github.com/ant-design/ant-motion/issues/44
.bezierEasingMixin();
^
Inline JavaScript is not enabled. Is it set in your options?

解决方法

less-load版本低于6.0时:vue.config.js 配置

module.exports = defineConfig({
  transpileDependencies: true,
  css: {
    loaderOptions: {
      less: {
        javascriptEnabled: true
      }
    }
  }
})

less-load版本高于6.0时:vue.config.js 配置

module.exports = defineConfig({
  transpileDependencies: true,
  css: {
    loaderOptions: {
      less: {
        lessOptions: {
          javascriptEnabled: true
        }
      }
    }
  }
})

ERROR Failed to compile with 1 error 上午12:48:06 error in ./pcExample/App.vue?vue&type=style&index=1&id=c93a566a&lang=less Syntax Error: // https://github.com/ant-design/ant-motion/issues/44 .bezierEasingMixin(); ^ Inline JavaScript is not enabled. Is it set in your options? Error in F:\故障自动分析与可视化\dash-board-ui\node_modules\ant-design-vue\lib\style\color\bezierEasing.less (line 110, column 0) ERROR in ./pcExample/App.vue?vue&type=style&index=1&id=c93a566a&lang=less (./node_modules/css-loader/dist/cjs.js??clonedRuleSet-32.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-32.use[2]!./node_modules/less-loader/dist/cjs.j s??clonedRuleSet-32.use[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./pcExample/App.vue?vue&type=style&index=1&id=c93a566a&lang=less) Module build failed (from ./node_modules/less-loader/dist/cjs.js): // https://github.com/ant-design/ant-motion/issues/44 .bezierEasingMixin(); ^ Inline JavaScript is not enabled. Is it set in your options? Error in F:\故障自动分析与可视化\dash-board-ui\node_modules\ant-design-vue\lib\style\color\bezierEasing.less (line 110, column 0) @ ./node_modules/vue-style-loader/index.js??clonedRuleSet-32.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-32.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-32.use[2]!./node_modules/less-loader/dist/cjs.js??clo nedRuleSet-32.use[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./pcExample/App.vue?vue&type=style&index=1&id=c93a566a&lang=less 4:14-414 15:3-20:5 16:22-422 @ ./pcExample/App.vue?vue&type=style&index=1&id=c93a566a&lang=less 1:0-472 1:0-472 @ ./pcExample/App.vue 5:0-75 @ ./pcExample/main.js 14:34-50 webpack compiled with 1 error
最新发布
09-12
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值