Variable Name Error “is undefined” even though “variables.less” imported

前端 未结 10 2023
清歌不尽
清歌不尽 2020-12-08 18:41

I started using LESS today. But it\'s kinda weird. This code does not work. I get an error:

! Variable Name Error: @linkColor in a is undefined.
10条回答
  •  感动是毒
    2020-12-08 19:11

    To help any others that may come across this not want duplicate CSS generated from multiple imports, you have two options.

    1. Either @import-once the variables / mixins files you need in each file you need to use them in.

      Use @import-once "filename.less"; to prevent duplicates.

    2. Upgrade to LESS > 1.4.0, when it arrives; From the less website:

      "The statement @import acts differently before and after 1.4.0. It acts as @import-multiple in all older versions and as @import-once in all less.js versions after 1.4.0."

提交回复
热议问题