可选参数可以在 LESS 中@font-file
获取值吗?@font-name
没有任何 javascript 评估...
.font-face(@font-name, @font-file: ???) {
font-family: '@{font-name}';
src: url('fonts/@{font-file}.eot');
src: url('fonts/@{font-file}.eot?#iefix') format('embedded-opentype'),
url('fonts/@{font-file}.svg#@{font-file}') format('svg'),
url('fonts/@{font-file}.woff') format('woff'),
url('fonts/@{font-file}.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
抱歉,如果这是一个很无聊的问题,我现在已经用 LESS 花了大约 2 个小时 :)
编辑:不复制mixin:
.font-face(@font-file) {
.font-face(@font-file, @font-file)
}
.font-face(@font-name, @font-file) {
font-family: '@{font-name}';
src: url('fonts/@{font-file}.eot');
src: url('fonts/@{font-file}.eot?#iefix') format('embedded-opentype'),
url('fonts/@{font-file}.svg#@{font-file}') format('svg'),
url('fonts/@{font-file}.woff') format('woff'),
url('fonts/@{font-file}.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}