如何在javascript中以90度显示风向(包括在数字后使用小圆圈度符号)?
我只能在文字说明中显示-以下代码。
谢谢。
function text(d) {
let directions = ['Northerly', 'North Easterly', 'Easterly', 'South Easterly', 'Southerly', 'South Westerly', 'Westerly', 'North Westerly'];
d += 22.5;
if (d < 0)
d = 360 - Math.abs(d) % 360;
else
d = d % 360;
let w = parseInt(d / 45);
return `${directions[w]}`;
}
非常容易:
function text(d) {
let directions = ['Northerly', 'North Easterly', 'Easterly', 'South Easterly', 'Southerly', 'South Westerly', 'Westerly', 'North Westerly'];
d += 22.5;
if (d < 0)
d = 360 - Math.abs(degree) % 360;
else
d = d % 360;
let w = parseInt(d / 45);
return `${directions[w]}`;
}
deg = 67;
console.log(deg + String.fromCharCode(0xfeff00b0) + ' = ' + text(deg));