mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
* change suffixes from md to mdx fix broken links for English locale tree shake and update docusaurus add docusaurus ideal image plugin use svg and themed image delete unused static asset * move localized landing page * change GitLocalize project page * nit pick * remove ignore to have the block checked
44 lines
600 B
Plaintext
44 lines
600 B
Plaintext
---
|
|
title: "Fragments"
|
|
---
|
|
|
|
import Tabs from '@theme/Tabs';
|
|
import TabItem from '@theme/TabItem';
|
|
|
|
The `html!` macro always requires a single root node. In order to get around this restriction, you
|
|
can use an "empty tag" (these are also called "fragments").
|
|
|
|
<Tabs>
|
|
<TabItem value="Valid" label="Valid">
|
|
|
|
```rust
|
|
use yew::html;
|
|
|
|
html! {
|
|
<>
|
|
<div></div>
|
|
<p></p>
|
|
</>
|
|
};
|
|
|
|
```
|
|
|
|
</TabItem>
|
|
|
|
<TabItem value="Invalid" label="Invalid">
|
|
|
|
```rust, compile_fail
|
|
use yew::html;
|
|
|
|
// error: only one root html element allowed
|
|
|
|
html! {
|
|
<div></div>
|
|
<p></p>
|
|
};
|
|
|
|
```
|
|
|
|
</TabItem>
|
|
</Tabs>
|