Friday:
Five Guys Vue lab
Have Vue read the file FiveGuys.json and generate two sets of radio buttons
(for sandwich and cook level) and two sets of checkboxes (for toppings and sides). Take the user's
order and display his/her choices. Determine the price -- sandwich plus any sides (toppings are free).
My file reading looked like:
fetch('FiveGuys.json')
.then(response => response.json())
.then(data => {
this.sandwiches = data.sandwich;
this.cook_levels = data.cook_level;
this.toppings = data.toppings;
this.sides = data.sides;
})
.catch(function(error){
console.log(error);
})
I gave the sandwiches and sides a change event v-on:change="calc"
(like the click event
in the Roman Numeral guessing game) and the handler looked like
methods: {
calc(){
//alert("HI");
this.total=0.0;
if(this.user_sandwich){
this.total = this.user_sandwich.sandwich_price;
}
for(i=0; i< this.user_sides.length; i++){
this.total += this.user_sides[i].side_price;
}
this.total = parseFloat(this.total).toFixed(2);
}
}
Due: Apr. 19