Links

setCss

说明

设置单个DOM样式

源码

用法

setCss.test.ts
import { setCss } from "../../utility/dom/setCss";
describe('setCss', () => {
test('setCss should receive a DOM object and CSS Rule options, add rules to DOM.', () => {
document.body.innerHTML = `
<div id="app">app</div>
`;
setCss(
document.getElementById('app') as HTMLElement,
{
color: 'red',
'font-size': 25,
},
);
expect((document.getElementById('app') as HTMLElement).getAttribute('style')).toBe('color: red; font-size: 25;');
});
});
最近更新 3yr ago