コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
4437 ビュー

I was trying to figure out how to stop a t-foreach loop after a certain amount of runs


f.e.: I want to print my 5 latest products with all varibales

" t-as="product">



Right now, it runs through all of my products, but i want to stop the list after 5 products.

Is there a possibility

アバター
破棄
最善の回答

you can use t-set / t-value to save any value.
then in for loop you can increment this value and use t-if against this.
but this will iterate through all products but display only 5.



アバター
破棄
最善の回答

Use line_index which comes with t-foreach. The index is 0 based, so subtract 1

t-if="line_index < 4"

アバター
破棄
関連投稿 返信 ビュー 活動
1
7月 24
8824
1
3月 15
17631
1
12月 23
2608
1
7月 25
1743
1
5月 25
1760