在Aurelia中,可以在重复中使用插槽来进行绑定吗?

编程入门 行业动态 更新时间:2024-10-23 19:33:56
本文介绍了在Aurelia中,可以在重复中使用插槽来进行绑定吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想创建一个遍历数组的自定义元素,并将其应用于数组中的每个项目.例如,自定义元素的视图模板将包含以下内容:

I'd like to create a custom element that loops through an array and applies the to each item in the array. For example, the view template of the custom element would contain something like:

<div repeat.for="i of items"> <div with.bind="i"> <slot></slot> </div> </div>

当我删除repeat.for和with.bind属性时,广告位显示一次.有没有一种方法可以使列表中的每个项目重复进行此操作?

When I remove the repeat.for and with.bind attributes, the slot displays a single time. Is there a way to make it repeat for each item in the list?

推荐答案

否,您今天不能将插槽与repeat.for或bind一起使用.为此,您必须使用可更换的零件.例如:

No, you cannot use slots with repeat.for or bind today. To do this you have to use replaceable parts. For example:

<div repeat.for="i of items"> <div with.bind="i"> <template replaceable part="content"></template> </div> </div>

用法:

<my-component> <template replace-part="content">Some Content - ${somePropertyOfI}</template> </my-component>

可运行的示例: gist.run/?id=29aa1c1199f080c9ba0e72845044799b

更多推荐

在Aurelia中,可以在重复中使用插槽来进行绑定吗?

本文发布于:2023-11-28 07:43:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641520.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:插槽   绑定   Aurelia

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!