mirror of
https://github.com/fumiama/paper-manager.git
synced 2026-06-09 18:30:23 +08:00
12 lines
418 B
TypeScript
12 lines
418 B
TypeScript
const docEle = document.documentElement
|
|
export function toggleClass(flag: boolean, clsName: string, target?: HTMLElement) {
|
|
const targetEl = target || document.body
|
|
let { className } = targetEl
|
|
className = className.replace(clsName, '')
|
|
targetEl.className = flag ? `${className} ${clsName} ` : className
|
|
}
|
|
|
|
export function setCssVar(prop: string, val: any, dom = docEle) {
|
|
dom.style.setProperty(prop, val)
|
|
}
|