labs / tiddlers / content / labs / lab10 / _Labs_10_Adding to the
@Mark George Mark George on 20 Sep 2021 522 bytes Complete lab 10

Once the user has entered the quantity and clicked the <

> button, we need to create a SaleItem and add it to the items arrary in the data store.

  1. The following is the data store mutation for adding to the items array:

     // add item to cart
     addItem(state, item) {
  2. You can use this mutation in a click handler function as follows:

    dataStore.commit("addItem", new SaleItem(this.product, this.quantity));