我想创建一个循环遍历数组并将其应用于数组中的每个项目的自定义元素。例如,自定义元素的视图模板将包含类似以下内容的内容:
<div repeat.for="i of items">
<div with.bind="i">
<slot></slot>
</div>
</div>
当我删除repeat.for和with.bind属性时,该槽会显示一次。有没有办法让它对列表中的每个项目重复?
不,您不能将插槽与repeat.for
or bind
今天。为此,您必须使用可更换零件。例如:
<div repeat.for="i of items">
<div with.bind="i">
<template replaceable part="content"></template>
</div>
</div>
Usage:
<my-component>
<template replace-part="content">Some Content - ${somePropertyOfI}</template>
</my-component>
可运行示例:https://gist.run/?id=29aa1c1199f080c9ba0e72845044799b https://gist.run/?id=29aa1c1199f080c9ba0e72845044799b
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)