我正在生成几个列类,其宽度在 Sass 地图中定义,如下所示:
$column-widths: 5 10 20 25 30 33 40 50 60 66 70 80 90 100;
@each $width in $column-widths {
.column-#{$width} {
width: #{$width}%;
}
}
Run Code Online (Sandbox Code Playgroud)
但是,我在编译时收到此错误:
Error in plugin 'sass'
Message:
grid.scss
Error: Invalid CSS after "...dth: #{$width}%": expected expression (e.g. 1px, bold), was ";"
on line 10 of grid.scss
>> width: #{$width}%;
----------------------^
Run Code Online (Sandbox Code Playgroud)
看起来它没有按照我预期的方式解释这一点。我想在百分号之前插入数值。但我认为它将它们作为字符串读取,然后尝试评估百分比并感到困惑。
我正在为D3 v4和D3 Scale Chromatic编写用于发散数字的连续色标.
这是我的功能:
var divergentColor = function(value, theDomain, interpolation) {
var theDomain = theDomain || [0, 50, 100];
var theInterpolation = interpolation || 'BrBg';
var scale = d3.scaleSequential()
.interpolator(d3['interpolate' + theInterpolation])
.domain(theDomain)
.clamp(true);
return scale(value);
};
divergentColor(25);Run Code Online (Sandbox Code Playgroud)
<script src="https://d3js.org/d3.v4.js"></script>
<script src="https://d3js.org/d3-scale-chromatic.v1.js"></script>Run Code Online (Sandbox Code Playgroud)
调用此函数时出现以下错误:
d3.v4.js:12808 Uncaught TypeError: interpolator is not a function
Run Code Online (Sandbox Code Playgroud)
这是D3的实现scaleSequential:https://github.com/d3/d3-scale/blob/master/src/sequential.js#L21
import {linearish} from "./linear";
export default function sequential(interpolator) {
var x0 = 0,
x1 = 1,
clamp = false;
function scale(x) { …Run Code Online (Sandbox Code Playgroud)