2017-06-29 31 views
0

我想使用帕格數據集屬性使塊。 問題是,當我將它們包含在一個頁面中時,它們內部有文本NaN(下圖)。我該如何解決它?如何使用Pug將數據集添加到div?

這裏是我的mixin

mixin products(src, head, price) 
    .favorites__block&attributes(attributes)= data-filter 
    .favorites__image 
     img(src=src, alt="").favorites__img 
    .favorites__text 
     span.favorites__title #{head} 
     span.favorites__price $#{price} 
     .favorites__btns 
     button.favorites__cart Add to cart 
     button.favorites__order Order 

我包括它的方式。

+products('assets/img/favorite_four.jpg', 'Machiato Coffee', '5')(data-filter='breakfast') 

enter image description here

回答

1

的問題是你附加到呼叫的(data-filter='breakfast')。現在,這個mixin調用現在有兩個參數列表,這是不允許的。但是,您可以通過將data-filter元素轉換爲mixin的參數來輕鬆解決此問題。

當我在代碼示例中這樣做時,它按預期工作(請參閱this CodePen以獲得說明)。

+1

非常感謝! – Allan