博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
插槽,具名插槽,作用域插槽_苗条的插槽
阅读量:2505 次
发布时间:2019-05-11

本文共 1529 字,大约阅读时间需要 5 分钟。

插槽,具名插槽,作用域插槽

Slots are a handy way to let you define components that can be composed together.

插槽是一种方便的方法,可让您定义可以组合在一起的组件。

And vice versa, depending on your point of view, slots are a handy way to configure a component you are importing.

反之亦然,根据您的观点,插槽是配置导入组件的便捷方法。

Here’s how they work.

这是他们的工作方式。

In a component you can define a slot using the <slot /> (or <slot></slot>) syntax.

在组件中,可以使用<slot /> (或<slot></slot> )语法定义<slot></slot>

Here’s a Button.svelte component that simply prints a <button> HTML tag:

这是一个Button.svelte组件,它仅打印一个<button> HTML标记:

For React developers, this is basically the same as <button>{props.children}</button>

对于React开发人员,这基本上与<button>{props.children}</button>

Any component importing it can define content that is going to be put into the slot by adding it into the component’s opening and closing tags:

任何导入它的组件都可以通过将其添加到组件的开始和结束标记中来定义将要放入插槽的内容:

You can define a default, which is used if the slot is not filled:

您可以定义一个默认值,如果未填充插槽,则使用该默认值:

You can have more than one slot in a component, and you can distinguish one from the other using named slots. The single unnamed slot will be the default one:

一个组件中可以有多个插槽,并且可以使用命名插槽将一个插槽与另一个插槽区分开。 单个未命名的插槽将是默认插槽:

Here’s how you would use it:

使用方法如下:

And this would render the following to the DOM:

这会将以下内容呈现给DOM:

Add this before

Add this after

翻译自:

插槽,具名插槽,作用域插槽

转载地址:http://itqgb.baihongyu.com/

你可能感兴趣的文章
Docker(三) 构建镜像
查看>>
FFmpeg 新旧版本编码 API 的区别
查看>>
RecyclerView 源码深入解析——绘制流程、缓存机制、动画等
查看>>
Android 面试题整理总结(一)Java 基础
查看>>
Android 面试题整理总结(二)Java 集合
查看>>
学习笔记_vnpy实战培训day02
查看>>
学习笔记_vnpy实战培训day03
查看>>
VNPY- VnTrader基本使用
查看>>
VNPY - CTA策略模块策略开发
查看>>
VNPY - 事件引擎
查看>>
MongoDB基本语法和操作入门
查看>>
学习笔记_vnpy实战培训day04_作业
查看>>
OCO订单(委托)
查看>>
学习笔记_vnpy实战培训day06
查看>>
回测引擎代码分析流程图
查看>>
Excel 如何制作时间轴
查看>>
matplotlib绘图跳过时间段的处理方案
查看>>
vnpy学习_04回测评价指标的缺陷
查看>>
iOS开发中遇到的问题整理 (一)
查看>>
Linux(SUSE 12)安装jboss4并实现远程访问
查看>>