Improving the UX with add to cart feedback
Our cart is now fully functional, and as such we could leave it as is. However, when clicking the Add to cart
button, there is no feedback as to whether or not something happened. Some online shops take you to the shopping cart page as and when you add a product to your cart, and if that's your preferred approach, then it should be a fairly simple change for you to add a page change as part of the button click handler. However, to demonstrate a different approach, we'll use a library called toastr
to provide instant feedback to the user that something positive happened.
Note
This section is completely optional, and will have no negative effects on the rest of the application if you choose to skip it for any reason!
First, we need to download a new npm module. The original toastr
library has a dependency on jQuery, so instead we'll use another open source alternative that is built specifically for use with Vue instead. Open Terminal and run the following...