本文整理匯總了TypeScript中inferno-create-element.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了default函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: createElement
it('should mount and unmount a basic component #2', () => {
let mountCount;
let unmountCount;
class ComponentLifecycleCheck extends Component<any, any> {
render() {
return createElement('div', null,
createElement('span', null)
);
}
componentDidMount() {
mountCount++;
}
componentWillUnmount() {
unmountCount++;
}
}
mountCount = 0;
unmountCount = 0;
render(createElement(ComponentLifecycleCheck, null), container);
expect(mountCount).to.equal(1);
render(null, container);
expect(unmountCount).to.equal(1);
render(createElement(ComponentLifecycleCheck, null), container);
expect(mountCount).to.equal(2);
render(null, container);
expect(unmountCount).to.equal(2);
});
示例2:
let template = (Component, title?) =>
createElement('div', null,
createElement(Component, {
title,
name: 'Hello, World!'
})
)
示例3: createElement
const template = (val?) => createElement('select', {
multiple: true,
value: val
}, createElement('option', {
value: 1
}, 1), createElement('option', {
value: 2
}, 2));
示例4: createElement
const app = () => {
return createElement('div', null,
createElement(Button, {
type: 'button',
children: ['Do a thing']
})
);
};
示例5: createElement
it("'abc' => null", () => {
const f = document.createDocumentFragment();
const a = createElement("div", null, "abc");
const b = createElement("div", null);
render(a, f);
render(b, f);
expect((f.firstChild as Element).childNodes.length).to.equal(0);
});