module.exports = {
css: {
loaderOptions: {
sass: {
prependData({resourcePath}) {
const vueFileName = resourcePath.match(/([^\\\/]+).vue$/i);
if(vueFileName)
return `$vue-file-name: "${vueFileName[1]}"`
}
}
}
}
}
В каждом Vue компоненте в sass у вас будет теперь переменная $vue-file-name
с именем файла. const data = [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8, 8.5, 9];
const data2 = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2];
function narrow(data, length, precision) {
const start = data[0];
const end = data[data.length-1];
const result = new Array(length);
let step = (end - start) / (length - 1);
if(precision) {
if(step < precision)
throw new RangeError(`Шаг не может быть кратен ${precision} при длине результирующего массива ${length}`);
step = (step / precision | 0) * precision;
}
result[0] = start;
while(--length)
result[length] = step * length;
return result;
}
console.log(
narrow(data, 5, 0.5)
)
console.log(
narrow(data2, 5)
)
console.log(
narrow(data, 5)
)
currentColor
, самому svg - boreder-radius
и background-color
.use href
.color
и background-color
.class Main {
constructor(public name: string) {}
}
class Sub extends Main {
constructor(name: string, public lastname: string) {
super(name)
}
}
const sub = new Sub('michael', 'jackson')
function hello (person: Main) {
console.log(person.name)
if(person instanceof Sub) {
console.log(person.lastname)
}
}
hello(sub)
console.log
не вызывает неявного приведения к строке, а потому в консоли мы увидим не 8
, а то что там и есть на самом деле, т.е. function inner() {}
toString
же неявно вызывается именно в случае использования объекта как строки. console.log(sum(1)(2)(2)(3) + 'px') // 8px
.