我尝试使用以下行让 simpleCart 购物车显示名称、价格和数量
<a class="item_add" href="javascript:;"> Add to Cart </a></p>
如文档和 simplecart.js 下载中包含的示例索引文件中所述。那没有显示项目名称。
索引文件还包括替代公式:
<a href="javascript:;" onclick="simpleCart.add({name:'baby lion', price: 34.95,size:'tiny',thumb:'e.png'});" >add to cart</a>
其中添加了名称、价格但数量错误。直接(即quantity: Quantity
)或通过 getElementById 方法(即quantity: document.getElementById("item_Quantity").value
)添加数量属性会导致错误。
我的购物车的栏目设置如下:
simpleCart({
cartColumns: [
{ attr: "name" , label: "Item"},
{ attr: "price" , label: "Price", view: 'currency' } ,
{ view: "decrement" , label: false , text: "-" } ,
{ attr: "quantity" , label: "Qty" } ,
{ view: "increment" , label: false , text: "+" } ,
{ attr: "total" , label: "SubTotal", view: 'currency' } ,
{ view: "remove" , text: "Remove" , label: false }
]
});
如何同时显示名称和数量?