本文整理汇总了TypeScript中react.createElement函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createElement函数的具体用法?TypeScript createElement怎么用?TypeScript createElement使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createElement函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: renderHTML
export function renderHTML(
ref: Reflection,
settings: Partial<ReactConverterSettings> = {}
): string {
const set = normalizeSettings(settings) as ViewSettings
if (ref.id) {
set.path = formatLink(ref.id).href
} else if (ref.kind === ReflectionKind.Search) {
set.path = '_search'
} else {
set.path = ''
}
const el = React.createElement(PageView, { reflection: ref, settings: set })
const html = renderToString(el)
const name = (ref as any).name || (ref.id && ref.id[ref.id.length - 1].name)
const base = path.relative(set.path, './')
return `
<html>
<head>
<meta charset="UTF-8">
<title>${name} - TypeScript</title>
<script>
__webpack_public_path__ = "${base}"
</script>
<base href="${base || '.'}" />
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css"/>
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Fira+Mono" rel="stylesheet">
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js" defer></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" defer></script>
<script crossorigin src="https://unpkg.com/prettier@1.14.3/standalone.js" defer></script>
<script crossorigin src="https://unpkg.com/prettier@1.14.3/parser-typescript.js" defer></script>
<link rel="stylesheet" type="text/css" href="${set.manifest['index.css']}"/>
<script>
window.__argv = ${JSON.stringify(set)}
var ref = "${encodeURIComponent(JSON.stringify(ref))}";
window.__ref = JSON.parse(decodeURIComponent(ref))
</script>
<script type="text/javascript" src="${set.manifest['index.js']}" defer></script>
</head>
<body class="${BodyStyle}">
${includeGoogleTracking(set)}
<div id='react-app'>${html}</div>
</body>
</html>
`
}
示例2: render
public render() {
const mp = this.props.MP;
const scores = [];
let i = 0;
for (i = 0; i < this.props.lobby.names.length; i = i + 1) {
scores.push(React.createElement(RockScissorsPaperRule.views['score'], {
name: this.props.lobby.names[i],
win: this.props.win[i],
draw: this.props.draw[i],
lose: this.props.lose[i]
}));
}
return mp.getPluginView('gameshell',
'HostShell-Main',
{
'links': {
'home': {
'icon': 'gamepad',
'label': 'Game',
'view': React.DOM.table(
null,
React.DOM.thead(null,
React.createElement(
RockScissorsPaperRule.views['scoreHeader'],
{})),
React.DOM.tbody(null,
scores))
},
'clients': {
'icon': 'users',
'label': 'Players',
'view': mp.getPluginView('lobby', 'host-roommanagement')
}
}
});
}
示例3: execute
async execute(event: InitShopEvent) : Promise<void> {
if (event.args[1]) {
switch (event.args[1]) {
case "filter":
event.view = React.createElement(Shop, {
childs: React.createElement(ShopFilter, {model: this.store.data.shop}),
model: this.store.data.shop
});
event.callBack();
return;
default:
if (!this.store.data.shop.selectedItem || this.store.data.shop.selectedItem.id !== event.args[1]) {
new GetShopItemsDetailsEvent(event.args[1]).dispatch();
return;
}
event.view = React.createElement(Shop, {
childs: React.createElement(ShopItem, {model: this.store.data.shop}),
model: this.store.data.shop
});
event.callBack();
return;
}
} else {
event.view = React.createElement(Shop, {model: this.store.data.shop});
}
if (!this.store.data.shop.init) {
event.callBack();
new GetShopItemsEvent().dispatch();
this.store.set("shop.init", true);
return;
}
event.callBack();
}
示例4: onRenderCell
@override
public onRenderCell(event: IFieldCustomizerCellEventParameters): void {
// Use this method to perform your custom cell rendering. The CellFormatter is a utility
// that you can use to convert the cellValue to a text string.
const value: string = event.cellValue;
const id: string = event.row.getValueByName('ID').toString();
const hasPermissions: boolean = this.context.pageContext.list.permissions.hasPermission(SPPermission.editListItems);
const toggle: React.ReactElement<{}> =
React.createElement(Toggle, { checked: value, id: id, disabled: !hasPermissions, onChanged: this.onToggleValueChanged.bind(this) } as IToggleProps);
ReactDOM.render(toggle, event.cellDiv);
}
示例5: test
test("can add font and background color classes", () => {
const el = shallow(
React.createElement(
Ansi,
{ useClasses: true },
`hello ${GREEN_FG}${YELLOW_BG}world`
)
);
expect(el).not.toBeNull();
expect(el.text()).toBe("hello world");
expect(el.html()).toBe(
"<code><span>hello </span><span class=\"ansi-yellow ansi-green\">world</span></code>"
);
});
示例6: render
public render(): void {
const element: React.ReactElement<IDropdownWithRemoteDataProps > = React.createElement(
DropdownWithRemoteData,
{
list: this.properties.list,
item: this.properties.item,
needsConfiguration: this.needsConfiguration(),
displayMode: this.displayMode,
configureWebPart: this.configureWebPart
}
);
ReactDom.render(element, this.domElement);
}
示例7: render
public render() {
return React.createElement('div', {
id: 'actionTimelinePopup',
className: 'actionPopup',
style: {
left: this.state.left,
top: this.state.top
}
} as React.DOMAttributes,
React.createElement('div', {
className: 'actionPopupTitle'
} as React.DOMAttributes, this.state.title),
React.createElement('button', {
className: 'removeFromTasklineButton',
onClick: this.removeFromTaskline.bind(this)
} as React.DOMAttributes, 'Remove from taskline'),
React.createElement('button', {
className: 'addToCalloutsButton',
id: 'addToCalloutsButton',
onClick: this.addToCallouts.bind(this)
} as React.DOMAttributes, 'Display as callout')
);
}