CodePudding user response:
Create a new empty array newArr inside the sessionStorage, each time you click on add insert a, of the same id number + 1Var newArr=[{
Id: "001",
Num: 2
}];
The shopping cart page access newArr
, of course, this is just a front end operations, if clear the cache won't get it, it is best to use a backend interface for storing and retrieving
CodePudding user response:
LocalStorage to read dataCodePudding user response:
Set up shopping cart object, this kind of circumstance can consider to use the singleton pattern