Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
355 views
in Technique[技术] by (71.8m points)

Svelte - how to use dot notation components

In react we can do

<SomeListComponent>
  <SomeListComponent.Item /> // Like this
</SomeListComponent>

is there a svelte equivalent of dot notation like in react?

question from:https://stackoverflow.com/questions/65600003/svelte-how-to-use-dot-notation-components

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Nope.

Unwrap it:

<script>
  ...
  const { Item } = SomeListComponent
</script>

<SomeListComponent>
  <Item />
</SomeListComponent>

Note, also, that the component name must be capitalized (<Item />, not <item /> -- or Svelte would consider it's a DOM element).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...