gpt4 book ai didi

javascript - 你能用 Stencil 中的 v-for 进行类比吗? (类似于 Stencil 中的 v-for)

转载 作者:行者123 更新时间:2023-11-28 17:08:23 25 4
gpt4 key购买 nike

我应该根据模板中的数组复制元素的一部分几次。我在 Vue 中使用了 v-for,但是我可以在 Stencil 中使用什么?

最佳答案

根据docs :

Loops can be created in JSX using either traditional loops when creating JSX trees, or using array operators such as map when inlined in existing JSX.

所以

render() {
return (
<div>
{this.items.map((item) =>
<div>
<div>{item.name}</div>
</div>
)}
</div>
)
}

应该大约相当于

<div v-for="item in items">
<div>{{ item.name }}</div>
...

关于javascript - 你能用 Stencil 中的 v-for 进行类比吗? (类似于 Stencil 中的 v-for),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55148716/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com