【问题标题】:How to add another each function in PUG如何在 PUG 中添加另一个每个函数
【发布时间】:2017-12-27 23:40:18
【问题描述】:
.product--production-wrapper.flex-row.col-x4
    - for (var i = 0; i < 6; i++)
    - var imagePath = ('assets/img/product-image/')
    each picture, bedFurniture in ['bed-1.jpg', 'bed-2.jpg', 'bed-3.jpg', 'bed-4.jpg', 'bed-5.jpg', 'bed-6.jpg']
        article.bed.card
            .product--image
                a(href="#"): img(src= imagePath + picture)
            .product--desc-wrapper.flex-row
                .product--name-href
                    h5 Product Name
                    a(href="#") Bed
                a(href="#").price $3999

我为 article 标签创建了一个循环和 each function for image 标签,但我不知道如何在此代码中为 Product NamePrice 添加每个函数。如果有人提供帮助,我将不胜感激。

【问题讨论】:

    标签: html iteration pug each


    【解决方案1】:
    .product--production-wrapper.flex-row.col-x4
        - for (var i = 0; i < 6; i++)
        - var imagePath = ('assets/img/product-image/')
        each item in [ {image: 'bed-1.jpg', price: '1999', name: 'product name 1'}, {image: 'bed-2.jpg', price: '345', name: 'product name 2'}, {image: 'bed-3.jpg', price: '2329', name: 'product name 3'} ]
            article.bed.card
                .product--image
                    a(href="#"): img(src=imagePath + item.image)
                .product--desc-wrapper.flex-row
                    .product--name-href
                        h5= item.name
                        a(href="#") Bed
                    a(href="#").price= item.price
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-28
      • 2016-08-26
      • 1970-01-01
      • 2021-09-29
      • 1970-01-01
      • 1970-01-01
      • 2020-02-26
      • 1970-01-01
      相关资源
      最近更新 更多