1

我正在关注 Lift 网站上的教程:http: //simply.liftweb.net/index-6.3.html#prev但我自己无法弄清楚如何在不关闭会话的情况下清空购物车内容。

4

1 回答 1

0

您可以将以下方法添加到类中,该方法将通过将 的内容替换为空Cart来清除购物车。ValueCellVector

def removeAllItems() = contents.atomicUpdate(v => Vector.empty)

Regis Jean-Gilles 的评论也将起作用,但使用该atomicUpdate方法将处理同步。

于 2013-01-21T20:44:23.573 回答