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

前端 未结 10 2026
清歌不尽
清歌不尽 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:17

    This other question ultimately led me to the right answer.

    It looks like the LESS compiler is silently failing if files are encoded with a BOM. (That's a Byte Order Mark for those not familiar with the term.) This is the default setting in some editors, such as Visual Studio.

    The compiler barfs up an error on the BOM if it's in your root file, but seems to fail silently for @import-ed files.

    Try saving your files as UTF-8 without a BOM, and see if that solves your problem.

提交回复
热议问题