【问题标题】:How to draw a conclusion from mixin PUG?如何从mixin PUG中得出结论?
【发布时间】:2018-02-10 05:27:11
【问题描述】:

我有一种商品的mixin,它还有其他几种myxins吗?其中包含数组,因此我在调用我的 maksin 的过程中遇到了输入数据的问题

这是您需要填充的数组之一:

+size-list(item.sized).--square.--product-item

mixin product-item(notice, name, price, size, old, oldprice, img, ...items)
+b.product-item
    +e.wrapper
        +e.compare
            +e.add.--compare(href="javascript:void(0);" title="")
                include ui-kit/icon.pug
                +icon("compare").--product-item
        +e.favorites
            +e.add.--favorites(href="javascript:void(0);" title="")
                include ui-kit/icon.pug
                +icon("favorites").--product-item
        if notice == 'vip'
            include ui-kit/label.pug
            +label('vip').--vip
        else if notice == 'hit'
            include ui-kit/label.pug
            +label('хит').--hit
        else if notice == 'new'
            include ui-kit/label.pug
            +label('new').--new
        else if notice == 'sale'
            include ui-kit/label.pug
            +label('%').--sale
        +b.button.--product-quck.js-qick-view(href="javascript:void(0);" title=name) быстрый просмотр
        +e.image-wrapper
            +e.image.js-wrapper-image(src=img, alt=name, title=name)
        +e.color
            include select-color.pug
            +select-color(...items).--product-item
        +e.info
            +e.name #{name}
            +e.size #{size}
            +e.hidden-info
                +e.size-change
                    include ui-kit/hr.pug
                    +hr().--product-item
                    include ui-kit/size-list.pug
                    
                    +size-list(item.sized).--square.--product-item
                               include characteristic-info.pug
                +characteristic-info({'items': [{
                        'title': 'Ш х В х Г',
                        'definition': '40 x 55 x 20/24 см'
                    },
                    {
                        'title': 'Объем',
                        'definition': '38/43 л'
                    },
                    {
                        'title': 'Масса',
                        'definition': '2,5 кг'
                    }
                ]}).--product-item
            include ui-kit/price.pug
            +price(price, old, oldprice, ".-").--product-item

结论本身试图这样做,但在括号上发誓:

+product-item("vip", "American Tourister Sunset Square Spinner 13G*908", "22 100", "Огромный чемодан-спиннер (XL)", "", "oldprice", "images/content/announcement-1.jpg", "", "#f3e222", "transparent", "#926ca7", "#926ca7", "#7fd0af", "#0bb8b2",{ 'items': [{
                        'size': [{
                            "textLabel": "XL",
                            "name": "size-105",
                            "id": "size-type-120",
                            "checked": true
                        }, {
                            "textLabel": "L",
                            "name": "size-105",
                            "id": "size-type-121"
                        }, {
                            "textLabel": "M",
                            "name": "size-105",
                            "id": "size-type-122"
                        }, {
                            "textLabel": "S",
                            "name": "size-105",
                            "id": "size-type-123"
                        }]
                    ]}
                })

我还有什么其他选择?我做错什么了?或者是否有可能设计mixin?

【问题讨论】:

    标签: pug


    【解决方案1】:

    就这样决定了

    mixin product-item(notice, name, price, size, old, oldprice, img, sized, info,...items)
        +b.product-item
            +e.wrapper
                +e.compare
                    +e.add.--compare(href="javascript:void(0);" title="")
                        include ui-kit/icon.pug
                        +icon("compare").--product-item
                +e.favorites
                    +e.add.--favorites(href="javascript:void(0);" title="")
                        include ui-kit/icon.pug
                        +icon("favorites").--product-item
                if notice == 'vip'
                    include ui-kit/label.pug
                    +label('vip').--vip
                else if notice == 'hit'
                    include ui-kit/label.pug
                    +label('хит').--hit
                else if notice == 'new'
                    include ui-kit/label.pug
                    +label('new').--new
                else if notice == 'sale'
                    include ui-kit/label.pug
                    +label('%').--sale
                +b.button.--product-quck.js-qick-view(href="javascript:void(0);" title=name) быстрый просмотр
                +e.image-wrapper
                    +e.image.js-wrapper-image(src=img, alt=name, title=name)
                
                +e.info
                    +e.info-text
                        include select-color.pug
                        +select-color(...items).--product-item
                        +e.name #{name}
                        +e.size #{size}
                    +e.hidden-info
                        +e.size-change
                            include ui-kit/hr.pug
                            +hr().--product-item
                            include ui-kit/size-list.pug
                            +size-list(sized).--square.--product-item
                        include characteristic-info.pug
                        +characteristic-info(info).--product-item
                    include ui-kit/price.pug
                    +price(price, old, oldprice, ".-").--product-item

    结论:

    +product-item("new", "American Tourister Sunset Square Spinner 13G*908", "22 100", "Огромный чемодан-спиннер (XL)", true, "24 500", "images/content/announcement-1.jpg",
                        [{
                            "textLabel": "XL",
                            "name": "size-100",
                            "id": "size-type-227",
                            "checked": true
                        }, {
                            "textLabel": "L",
                            "name": "size-100",
                            "id": "size-type-228"
                        }, {
                            "textLabel": "M",
                            "name": "size-100",
                            "id": "size-type-229"
                        }, {
                            "textLabel": "S",
                            "name": "size-100",
                            "id": "size-type-230"
                        }],
                        [{
                            'title': 'Ш х В х Г',
                            'definition': '40 x 55 x 20/24 см'
                        },
                        {
                            'title': 'Объем',
                            'definition': '38/43 л'
                        },
                        {
                            'title': 'Масса',
                            'definition': '2,5 кг'
                        }], "", "#f3e222", "transparent", "#926ca7", "#926ca7", "#7fd0af", "#0bb8b2")

    【讨论】:

      猜你喜欢
      • 2018-07-02
      • 2012-10-17
      • 1970-01-01
      • 2021-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多