const list = [
{id:1, pid:0},
{id:2, pid:0},
{id:3, pid:2},
{id:4, pid:2},
{id:5, pid:3},
{id:6, pid:5},
];
function removeById(id) {
const index = list.findIndex(item => item.id === id);
if (index === -1) {
return;
}
list.splice(index, 1);
const items = list.filter(item => item.pid === id);
items.forEach(item => removeById(item.id));
}
removeById(id);
import Vue from "vue";
import ElementUI from 'element-ui';
Vue.use(ElementUI);
import {mount} from '@vue/test-utils'
import register from '@/components/form-reg.vue'
describe('Register', () => {
const wrapper = mount(register, {
stubs: {
'el-row': '<div></div>'
}
})
it('имеет кнопку', () => {
expect(wrapper.contains('button')).toBe(true)
})
})
<a id="incrementButton" style="color:green;" href="#">[+1]</a>
<div id="item"></div>
const item = document.getElementById('item');
const incrementButton = document.getElementById('incrementButton');
let cost = 0; // Текущее число
incrementButton.addEventListener('click', () => {
cost++;
item.innerHTML = cost;
});
item.innerHTML = cost;
const v1 = 100;
const count = getComputedStyle(document.documentElement).getPropertyValue('--count');
const width = `calc(100% / ${count} * ${v1})`;
document.querySelector('div').style.width = width;
<div>TEST</div>
:root {
--count: 50;
}
div {
border: 1px solid red;
}
var(--count)
не выполнится в этом контексте и надо получить значение CSS переменной через getComputedStyle(document.documentElement).getPropertyValue('--count')
. $ node ./app.js; node ./app2.js // выполнит по очереди
$ node ./app.js && node ./app2.js // выполнит по очереди, но вторая команда выполнится только первая не упадёт