Svelte.js 面试题与答案
问题 11. How can you pass data between parent and child components in Svelte?
Data can be passed from parent to child components in Svelte using props. The parent component can bind a variable to a child component property, ensuring updates are reflected in the child.
问题 12. Explain the purpose of the 'await' block in Svelte.
The 'await' block in Svelte is used for asynchronous logic. It allows you to await a Promise and handle the resolved value or catch errors within the template.
问题 13. What are Svelte transitions, and how do you use them?
Svelte transitions enable smooth animations during element insertion, removal, or state changes. You can use 'in:' and 'out:' directives to specify transition effects.
问题 14. How does Svelte handle global CSS styles?
Svelte allows you to include global CSS styles using the 'global' keyword. Styles defined with 'global' apply globally across all components.
问题 15. Explain the role of the 'key' attribute in Svelte's each block.
The 'key' attribute in Svelte's each block is used to uniquely identify elements during iteration. It helps Svelte efficiently update the DOM when the list changes.
用户评价最有帮助的内容:
- What is Svelte.js?
- Explain the concept of reactivity in Svelte.
- How can you perform conditional rendering in Svelte?
- What is the purpose of the 'on:' directive in Svelte?
- How does Svelte handle global CSS styles?