2017-05-25 66 views
0

我正在为学习目的创建电子商务网站,并且出现问题。我使用BEM命名约定,我不知道如果我这样做很好,这里是我的代码:与BEM命名约定相混淆 - 需要更正?

<div class="product product--miniature" data-id-product="{$product.id_product}" data-id-product-attribute="{$product.id_product_attribute}" itemscope itemtype="http://schema.org/Product"> 
    <figure class="product__thumbnail"> 
    <div class="product__badges"> 
     <span class="badge badge--{$flag.type}">{$flag.label}</span> 
    </div> 
    <img src="{$product.cover.medium.url}" alt="{$product.cover.legend}" data-full-size-image-url="{$product.cover.large.url}"> 
    </figure> 
    <div class="product__info"> 
    <h3 class="product__name" itemprop="name"><a href="{$product.url}">{$product.name}</a></h3> 
    <div class="product__prices"> 
     <span class="price" itemprop="price">{$product.price}</span> 
     <span class="price--discount">{$product.regular_price}</span> 
    </div> 
    </div> 
</div> 

我最大的问题与产品徽章和产品的价格,我认为有些事情在有错?

+0

对我来说一切似乎都很好。只要你避免使用许多ID(并且在任何情况下都不要使用duplicateID)并且使用类并以暗示的方式命名你的元素,我看不到问题。有关更详细的答案,你应该看看https://codereview.stackexchange.com/ –

回答

1

我可以看到这里唯一要考虑的是使用pricebadge块类。如果他们可以独立存在(product区块以外),那么你有什么好的。但是,如果他们只会存在于产品内部,那么您可能会喜欢将它们更改为product__priceproduct__badge