Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. <template>
  2. <div class="container border border-primairy p-3 m-3 bg-light">
  3. <div class="">
  4. <div v-for="item in stocks" :key="item.id">
  5. <div class="border border-primairybg-light p-3 m-3 w-50 h-25"
  6. v-bind:style="{ backgroundColor: item.color}">
  7. <p>{{item.name}} (price: {{item.price}})</p>
  8. <input type="text" class="form-control w-25 d-inline" placeholder="Quantity">
  9. <button type="button" class="m-3 btn btn-primary" v-on:click="buy(item)">Buy</button>
  10. </div>
  11. </div>
  12. </div>
  13. </div>
  14.  
  15. </template>
  16. <script>
  17. import VueRouter from 'vue-router'
  18.  
  19. import {
  20. routes
  21. } from '../routes';
  22.  
  23. import {
  24. store
  25. } from '../store/store';
  26.  
  27. import {
  28. eventBus
  29. } from '../main.js';
  30.  
  31. export default {
  32. data() {
  33. return {
  34. stocks: [],
  35. color: '',
  36. renderComponent: true,
  37. };
  38. },
  39. created() {
  40. this.stocks = store.getters.stocks;
  41. },
  42. methods: {
  43. buy(item) {
  44. store.dispatch('buy', item)
  45. },
  46. }
  47. }
  48. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement