判断展开/收起的dom显示和隐藏,小于68隐藏功能
获取dom结构,页面数据page_list
const dom_text = document.querySelectorAll('.circular_text') as any;
const heights: any = [];
dom_text.forEach((item: any, index: number) => {
// console.log(item.offsetHeight)
if (item.offsetHeight > 68) {
heights.push(true);
dom_text[index].style.height = '68px';
} else {
heights.push(false);
}
})
this.page_list.forEach((item: any, index: number) => {
item.isShowItem = heights[index];
});
lick事件
// 展开-收起题干
private show_theme(ev: any) {
// console.log(ev);
ev.target.style.display = 'none';
ev.target.nextSibling.style.display = 'block';
ev.target.previousSibling.style.height = 'auto';
ev.target.previousSibling.style.maxHeight = 'inherit';
}
private cancel_theme(ev: any) {
ev.target.style.display = 'none';
ev.target.parentElement.firstChild.style.maxHeight = '68px';
ev.target.previousSibling.style.display = 'block';
}